ref: aca5dbbb60071a002ccca83b9a02e65b660b8c3e
dir: /testdir/test42.in/
Test for writing and reading a file starting with a BOM STARTTEST :so mbyte.vim :set encoding=utf-8 :set fileencodings=ucs-bom,latin-1 :set ff=unix ffs=unix " This changes the file for DOS and MAC :" --- Write the test files :/^latin-1$/+1w! Xtest0 :/^utf-8$/+1w! Xtest1 :/^utf-8-err$/+1w! Xtest2 :/^ucs-2$/+1w! Xtest3 :/^ucs-2le$/+1w! Xtest4 :" Need to add a NUL byte after the NL byte :set bin :e! Xtest4 " Ignore change from setting 'ff' o:set noeol :w :set ffs& nobinary " Allow default test42.in format :e # :set ff=unix " Format for files to write :/^ucs-4$/+1w! Xtest5 :/^ucs-4le$/+1w! Xtest6 :" Need to add three NUL bytes after the NL byte :set bin :e! Xtest6 " ! for when setting 'ff' is a change o:set noeol :w :set nobin :e # :" :" --- Check that editing a latin-1 file doesn't see a BOM :e! Xtest0 :redir! >test.out :set fileencoding bomb? :redir END :set fenc=latin-1 :w >>test.out :set bomb fenc=latin-1 :w! Xtest0x :" :" --- Check utf-8 :e! Xtest1 :redir >>test.out :set fileencoding bomb? :redir END :set fenc=latin-1 :w >>test.out :set fenc=utf-8 :w! Xtest1x :" :" --- Check utf-8 with an error (will fall back to latin-1) :e! Xtest2 :redir >>test.out :set fileencoding bomb? :redir END :set fenc=latin-1 :w >>test.out :set fenc=utf-8 :w! Xtest2x :" :" --- Check ucs-2 :e! Xtest3 :redir >>test.out :set fileencoding bomb? :redir END :set fenc=latin-1 :w >>test.out :set fenc=ucs-2 :w! Xtest3x :" :" --- Check ucs-2le :e! Xtest4 :redir >>test.out :set fileencoding bomb? :redir END :set fenc=latin-1 :w >>test.out :set fenc=ucs-2le :w! Xtest4x :" :" --- Check ucs-4 :e! Xtest5 :redir >>test.out :set fileencoding bomb? :redir END :set fenc=latin-1 :w >>test.out :set fenc=ucs-4 :w! Xtest5x :" :" --- Check ucs-4le :e! Xtest6 :redir >>test.out :set fileencoding bomb? :redir END :set fenc=latin-1 :w >>test.out :set fenc=ucs-4le :w! Xtest6x :" :" --- Check the files written with BOM :set bin :e! test.out :$r Xtest0x :$r Xtest1x :$r Xtest2x :$r Xtest3x :$r Xtest4x :$r Xtest5x :$r Xtest6x :set nobin ff& " Write the file in default format :w! test.out :qa! ENDTEST latin-1 ��latin-1 utf-8 utf-8 utf-8-err utf-8�err ucs-2 ��ucs-2 ucs-2le ��ucs-2le ucs-4 ��ucs-4 ucs-4le ��ucs-4le