1Test for writing and reading a file starting with a BOM 2 3STARTTEST 4:so mbyte.vim 5:set encoding=utf-8 6:set fileencodings=ucs-bom,latin-1 7:set ff=unix ffs=unix " This changes the file for DOS and MAC 8:" --- Write the test files 9:/^latin-1$/+1w! Xtest0 10:/^utf-8$/+1w! Xtest1 11:/^utf-8-err$/+1w! Xtest2 12:/^ucs-2$/+1w! Xtest3 13:/^ucs-2le$/+1w! Xtest4 14:" Need to add a NUL byte after the NL byte 15:set bin 16:e! Xtest4 " Ignore change from setting 'ff' 17o:set noeol 18:w 19:set ffs& nobinary " Allow default test42.in format 20:e # 21:set ff=unix " Format for files to write 22:/^ucs-4$/+1w! Xtest5 23:/^ucs-4le$/+1w! Xtest6 24:" Need to add three NUL bytes after the NL byte 25:set bin 26:e! Xtest6 " ! for when setting 'ff' is a change 27o:set noeol 28:w 29:set nobin 30:e # 31:" 32:" --- Check that editing a latin-1 file doesn't see a BOM 33:e! Xtest0 34:redir! >test.out 35:set fileencoding bomb? 36:redir END 37:set fenc=latin-1 38:w >>test.out 39:set bomb fenc=latin-1 40:w! Xtest0x 41:" 42:" --- Check utf-8 43:e! Xtest1 44:redir >>test.out 45:set fileencoding bomb? 46:redir END 47:set fenc=latin-1 48:w >>test.out 49:set fenc=utf-8 50:w! Xtest1x 51:" 52:" --- Check utf-8 with an error (will fall back to latin-1) 53:e! Xtest2 54:redir >>test.out 55:set fileencoding bomb? 56:redir END 57:set fenc=latin-1 58:w >>test.out 59:set fenc=utf-8 60:w! Xtest2x 61:" 62:" --- Check ucs-2 63:e! Xtest3 64:redir >>test.out 65:set fileencoding bomb? 66:redir END 67:set fenc=latin-1 68:w >>test.out 69:set fenc=ucs-2 70:w! Xtest3x 71:" 72:" --- Check ucs-2le 73:e! Xtest4 74:redir >>test.out 75:set fileencoding bomb? 76:redir END 77:set fenc=latin-1 78:w >>test.out 79:set fenc=ucs-2le 80:w! Xtest4x 81:" 82:" --- Check ucs-4 83:e! Xtest5 84:redir >>test.out 85:set fileencoding bomb? 86:redir END 87:set fenc=latin-1 88:w >>test.out 89:set fenc=ucs-4 90:w! Xtest5x 91:" 92:" --- Check ucs-4le 93:e! Xtest6 94:redir >>test.out 95:set fileencoding bomb? 96:redir END 97:set fenc=latin-1 98:w >>test.out 99:set fenc=ucs-4le 100:w! Xtest6x 101:" 102:" --- Check the files written with BOM 103:set bin 104:e! test.out 105:$r Xtest0x 106:$r Xtest1x 107:$r Xtest2x 108:$r Xtest3x 109:$r Xtest4x 110:$r Xtest5x 111:$r Xtest6x 112:set nobin ff& " Write the file in default format 113:w! test.out 114:qa! 115ENDTEST 116 117latin-1 118��latin-1 119utf-8 120utf-8 121utf-8-err 122utf-8�err 123ucs-2 124��ucs-2 125ucs-2le 126��ucs-2le 127ucs-4 128��ucs-4 129ucs-4le 130��ucs-4le 131