Home > Net >  StreamReader garbled question (the.net Core console cannot solve the code, however. The.net Framewor
StreamReader garbled question (the.net Core console cannot solve the code, however. The.net Framewor

Time:10-08

CodePudding user response:

Streamreader not. The Core

CodePudding user response:

Modify the code format, not necessarily with the default encoding format

CodePudding user response:

refer to the second floor jx315425246 response:
modify the code format, not necessarily with the default encoding format

Coding I replace all right, are not well

CodePudding user response:

You will receive is ASCII

CodePudding user response:

Also is wrong, this is not the ASCII

CodePudding user response:

This is because the Net more for Linux Core, MacOX system, such as Microsoft document written like this:
reference
.net Core the default attribute
In the.net Core Default attribute always return UTF8Encoding , and all operating systems (Windows, Linux, and maximum OS X) running on the. NET Core application support utf-8,

https://docs.microsoft.com/zh-cn/dotnet/api/system.text.encoding.default? View=netframework 4.8

You can detect Chinese Windows system in the code, and set Encoding for Encoding. GetEncoding (such as "gb2312")
 
Var reader=new StreamReader (fs, Encoding GetEncoding (" gb2312 "))
.

CodePudding user response:

After the test, there is this problem
Version 2.2 is
Version 1.0, no default Encoding Encoding format

Various formats are not, seems not support Chinese

CodePudding user response:

refer to 6th floor github_36000833 response:
this is because the Net more for Linux Core, MacOX system, such as Microsoft document written like this:
reference
.net Core the default attribute
In the.net Core Default attribute always return UTF8Encoding , and all operating systems (Windows, Linux, and maximum OS X) running on the. NET Core application support utf-8,

https://docs.microsoft.com/zh-cn/dotnet/api/system.text.encoding.default? View=netframework 4.8

You can detect Chinese Windows system in the code, and set Encoding for Encoding. GetEncoding (such as "gb2312")
 
Var reader=new StreamReader (fs, Encoding GetEncoding (" gb2312 "))
.

Gb2312 also used, but also not line

CodePudding user response:

Can run on the command line CHCP page to check the system Default language code (namely NetFramework next Encoding. The Default results),
C: \ & gt; CHCP

If get
850, the default code page is DOS Latin 1;
GB 54936, 18030;

Specific Code, can refer to Microsoft's Code Page Identifiers
https://docs.microsoft.com/zh-cn/windows/win32/intl/code-page-identifiers

You can first try Encoding blindly. GetEncoding (" GB18030 "), and so on,

CodePudding user response:

reference dreamer NO1 reply: 3/f
Quote: refer to the second floor jx315425246 response:
modify the code format, not necessarily with the default encoding format

Coding I replace all right, can't oh

Change Encoding. The Default
Unicode
Encoding.
A total of these coding
Unicode
Encoding.Encoding. UTF32
Encoding. UTF7
. Encoding UTF8
Encoding. The ASCII

One by one

CodePudding user response:

CodePudding user response:

The
reference 11 floor Demons1874 reply:

Have a problem that should be my environment, I change the SDK

CodePudding user response:

refer to 12 floor dreamer NO1 reply:
Quote: refer to the 11 floor Demons1874 response:

It should be alright with my environment, I change the SDK


I think I know what's the problem, should be Windows notepad, you try to use other editor to create a file, such as notepad + +, or D:/log. TXT file save as to select encoding format for UTF8, save and then read a try

CodePudding user response:

reference 13 floor Demons1874 reply:
Quote: refer to 12 floor dreamer NO1 reply:

Quote: refer to the 11 floor Demons1874 response:

It should be alright with my environment, I change the SDK


I think I know what's the problem, should be Windows notepad, you try to use other editor to create a file, such as notepad + +, or D:/log. TXT file save as to select encoding format for UTF8, save and then try to read

Save the notepad have four right, not only the first format, the other 3 are ok

CodePudding user response:

I am really convinced,

nullnullnullnullnullnullnullnull
  •  Tags:  
  • C#
  • Related