表示字符编码。若要浏览此类型的.NET Framework 源代码,请参阅 Reference Source。
TextEncodings
01 Syntax
Microsoft.VisualBasic.Text.TextEncodings
02 Methods
| Name | Overloads | Summary |
|---|---|---|
| codePageTable | 1 | 在这个函数之中会根据当前所运行的平台对utf8编码进行一下额外的处理 |
| .cctor | 1 | 构造函数会自动的从命令行配置之中设置默认的编码格式 |
| __gbk2312_encoding | 1 | 在linux上面如果没有安装gb2312的话,会出错,则这个函数会默认使用UTF8编码 并给出警告信息 |
| CodePage | 2 | Get text file save Encoding instance |
| ParseEncodingsName | 1 | 从字符串名称之中解析出编码格式的枚举值(名称的大小写不敏感) |
| TransEncoding | 1 | 有时候有些软件对文本的编码是有要求的,则可以使用这个函数进行文本编码的转换 例如R程序默认是读取ASCII,而。NET的默认编码是UTF8,则可以使用这个函数将目标文本文件转换为ASCII编码的文本文件 |
| GetString | 1 | |
| GetEncodings | 1 | |
| CodeArray | 1 |
03 Properties
| Name | Overloads | Summary |
|---|---|---|
| DefaultEncoding | 1 | Encoding.Default (获取操作系统的当前 ANSI 代码页的编码。这个属性可以通过default_encoding环境参数来设置) |
| UTF8 | 1 | UTF-8 without BOM.(获取 UTF-8 格式的编码。Encoding.UTF8默认是带有BOM标记的,这里使用无BOM标记的UTF8编码) |
| TextEncodings | 1 | 编码由枚举类型Encodings到Encoding之间的映射 |
| UTF8WithoutBOM | 1 |
04 Fields
| Name | Overloads | Summary |
|---|---|---|
| encodingFlags | 1 | use for parse encoding flags from string |
05 Members
codePageTable
在这个函数之中会根据当前所运行的平台对utf8编码进行一下额外的处理
#cctor
构造函数会自动的从命令行配置之中设置默认的编码格式
Remarks
Linux下面提示 Encoding 936 data could not be found.
处理方法
- 应该首先
locale -a看有没有安装gbk - 没安装的话需要先安装gbk编码
- 然后再安装
mono-locale-extras
locale -a
yum install -y mono-locale-extras__gbk2312_encoding
在linux上面如果没有安装gb2312的话,会出错,则这个函数会默认使用UTF8编码 并给出警告信息
Remarks
If the linux server didn't enable the gb2312 text encoding, then this exception happends...
[ERROR] FATAL UNHANDLED EXCEPTION: System.Exception: [Path] /home/software/cytonetwork.test/cytonetwork ---> System.Exception: [DIR] /home/software/cytonetwork.test ---> System.TypeInitializationException: The type initializer for 'Microsoft.VisualBasic.Text.TextEncodings' threw an exception. ---> System.NotSupportedException: Encoding 936 data could not be found. Make sure you have correct international codeset assembly installed and enabled.
at System.Text.Encoding.GetEncoding (System.Int32 codepage) [0x0023f] In <902ab9e386384bec9c07fa19aa938869>:0
at System.Text.Encoding.GetEncoding (System.String name) [0x00012] In <902ab9e386384bec9c07fa19aa938869>:0
at Microsoft.VisualBasic.Text.TextEncodings..cctor () [0x00030] In <00ade39f7ffc4ab69ceb325aefc4ee1b>:0
--- End of inner exception stack trace ---
at Microsoft.VisualBasic.TextDoc.SaveTo (System.String text, System.String path, System.Text.Encoding encoding, System.Boolean append, System.Boolean throwEx) [0x00063] In <00ade39f7ffc4ab69ceb325aefc4ee1b>:0
--- End of inner exception stack trace ---
--- End of inner exception stack trace ---
at Microsoft.VisualBasic.TextDoc.SaveTo (System.String text, System.String path, System.Text.Encoding encoding, System.Boolean append, System.Boolean throwEx) [0x000a7] In <00ade39f7ffc4ab69ceb325aefc4ee1b>:0
at Microsoft.VisualBasic.Language.UnixBash.LinuxRunHelper.BashShell () [0x0001b] In <00ade39f7ffc4ab69ceb325aefc4ee1b>:0
at Microsoft.VisualBasic.CommandLine.Interpreter.__methodInvoke (System.String commandName, System.Object[] argvs, System.String[] help_argvs) [0x001c9] In <00ade39f7ffc4ab69ceb325aefc4ee1b>:0
at Microsoft.VisualBasic.CommandLine.Interpreter.Execute (Microsoft.VisualBasic.CommandLine.CommandLine args) [0x00024] In <00ade39f7ffc4ab69ceb325aefc4ee1b>:0
at Microsoft.VisualBasic.App.RunCLI (System.Type Interpreter, Microsoft.VisualBasic.CommandLine.CommandLine args, System.String caller) [0x00012] In <00ade39f7ffc4ab69ceb325aefc4ee1b>:0
at cytonetwork.Program.Main () [0x0000f] In <0Fa3aca1569b43dc8ca208295f3a029d>:0CodePage(Encodings)
Get text file save Encoding instance
Parameters
| Name | Type | Description |
|---|---|---|
value | Encodings | - |
ParseEncodingsName(
String, Encodings)从字符串名称之中解析出编码格式的枚举值(名称的大小写不敏感)
Parameters
| Name | Type | Description |
|---|---|---|
encoding | String | 名称的大小写不敏感 |
onFailure | Encodings | - |
有时候有些软件对文本的编码是有要求的,则可以使用这个函数进行文本编码的转换 例如R程序默认是读取ASCII,而。NET的默认编码是UTF8,则可以使用这个函数将目标文本文件转换为ASCII编码的文本文件
Parameters
| Name | Type | Description |
|---|---|---|
path | String | - |
encoding | Encodings | - |
from | Encoding | - |
DefaultEncoding
Encoding.Default
(获取操作系统的当前 ANSI 代码页的编码。这个属性可以通过default_encoding环境参数来设置)
UTF8
UTF-8 without BOM.(获取 UTF-8 格式的编码。Encoding.UTF8默认是带有BOM标记的,这里使用无BOM标记的UTF8编码)
TextEncodings
编码由枚举类型Encodings到Encoding之间的映射
Remarks
可能在Linux服务器上面没有使用gb2312编码集合,则在这个模块之中初始化会出错
locale -a
yum install -y mono-locale-extrasencodingFlags
use for parse encoding flags from string
UTF8WithoutBOM
CodePage(
String, Encodings)GetEncodings(
Encoding)CodeArray(
IEnumerable(Of Char))