Created
November 19, 2010 13:44
-
-
Save NeilRobbins/706528 to your computer and use it in GitHub Desktop.
The System.Text.UTF8Encoding class provides a constructor which allows the client to specify whether a BOM mark should be included. It doesn't seem to work.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Keep in mind the documentation for this constructor which says "A parameter specifies whether to provide a Unicode byte order mark" & "true to specify that a Unicode byte order mark is provided; otherwise, false." | |
-- Whilst the standard allows (but does not recommend) for the optional BOM mark to be included, Excel 2003 seems to require it when reading a UTF-8 encoded csv. | |
> let encoderWithBOM = new UTF8Encoding(true);; | |
val encoderWithBOM : UTF8Encoding | |
> let encodedText = encoderWithBOM.GetBytes("Some Text");; | |
val encodedText : byte [] = | |
[|83uy; 111uy; 109uy; 101uy; 32uy; 84uy; 101uy; 120uy; 116uy|] | |
> let encoderWithoutBom = new UTF8Encoding(false);; | |
val encoderWithoutBom : UTF8Encoding | |
> let bomlessEncodedText = encoderWithoutBom.GetBytes("Some Text");; | |
val bomlessEncodedText : byte [] = | |
[|83uy; 111uy; 109uy; 101uy; 32uy; 84uy; 101uy; 120uy; 116uy|] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment