Home > Net >  Is there any difference between these two lines?
Is there any difference between these two lines?

Time:01-26

Is there any difference between these two lines?
Byte [] b1.=Encoding UTF8. GetBytes (s);
Byte [] b2=Encoding. GetEncoding (" utf-8 "). GetBytes (s);

CodePudding user response:

There is no difference, realized the function of the same

CodePudding user response:

Functions, implementation is different

CodePudding user response:



 

//
//abstract:
//Returns the encoding associated with the specified code page name.
//
//parameters:
//name:
//The code page, The name of The preferred encoding. Any value returned by The System. Text. Encoding. WebName
//property is valid. Possible values are listed in the Name column of the table
//that appears in the System. Text. Encoding the class topic.
//
//return the result:
//The encoding associated with The specified code page.
//
//exception:
//T: System. ArgumentException:
//The name is not a valid code page name. - or - The code page indicated by The name is not
//supported by the physicist platform.
Public static Encoding GetEncoding (string name)
{
Encoding ret=null;

The switch (name)
{//...
Case "utf-8" :
Ret=UTF8;
break;
//...
}
return ret;

}




Only on the operating efficiency, the subtle difference between may return to Encoding in according to the name above, is no different from other places, is a thing

CodePudding user response:

[quote=reference 3 floor 灬

Only on the operating efficiency, the subtle difference between may return to Encoding in according to the name above, is no different from other places, is a thing


I test in Chinese and return is the same, but three months ago I made a project, using the zebra printer to print label, there are Chinese, then find the first line print out Chinese is garbled (out), the second line can be printed out in Chinese, when the time is tight, no more, now have time to take out the orders on hand have no equipment, so posted on here to see you have not met this kind of thing,

CodePudding user response:

Loved the
reference 4 floor response:
[quote=reference 3 floor 灬

Only on the operating efficiency, the subtle difference between may return to Encoding in according to the name above, is no different from other places, is a thing


I test in Chinese and return is the same, but three months ago I made a project, using the zebra printer to print label, there are Chinese, then find the first line print out Chinese is garbled (out), the second line can be printed out in Chinese, when the time is tight, no more, now have time to take out the orders on hand have no equipment, so posted on here to see you have not met this kind of thing,


Hello, I again take a closer look at two ways of results, the generated object, use the DLL, found that they are the same, is my platform. Netcore 3.1 considering platform code problem?

CodePudding user response:

This is a problem left over by history, current.net core are all unification, the end of the current version at sixes and sevens,
  •  Tags:  
  • C#
  • Related