zoukankan      html  css  js  c++  java
  • C#创建UTF8无BOM文本文件

    In order to omit the byte order mark (BOM), your stream must use a custom instance of UTF8Encoding instead of the default System.Text.Encoding.UTF8:

    1.Call the UTF8Encoding constructor with False for the encoderShouldEmitUTF8Identifier parameter.

    2.Pass the UTF8Encoding instance to the stream constructor.

    实例:

    var utf8WithoutBom = new System.Text.UTF8Encoding(false);
                                                    //^^^^^
    using (var sink = new StreamWriter("Foobar.txt", false, utf8WithoutBom))
    {
        sink.WriteLine("...");
    }

    Note that omitting the BOM is only permissible for UTF-8, not for UTF-16.

  • 相关阅读:
    31
    30
    29
    28
    27
    26
    25
    23
    cesium 基础
    操作SDO_GEOMETRY字段
  • 原文地址:https://www.cnblogs.com/weekend001/p/3662903.html
Copyright © 2011-2022 走看看