C # simplified and traditional Chinese character conversion (original wanyahu)

Source: Internet
Author: User
Tags getsimple

Public string TranToTrade (string text) // convert to traditional
{
If (text. ToString (). Length> 0)
{
String Sstr = Conversions. ToString (this. getSimple ());
String Tstr = Conversions. ToString (this. getTrade ());
Char [] TradeArr = Tstr. ToCharArray (0, Tstr. Length-1 );
Int VB $ t_i4 $ L0 = text. Length-1;
For (int I = 0; I <= VB $ t_i4 $ L0; I ++)
{
Char oldstr = Conversions. ToChar (text. Substring (I, 1 ));
If (Sstr. Contains (Conversions. ToString (oldstr )))
{
Char newstr = TradeArr [Sstr. IndexOf (oldstr)];
Text = text. Replace (oldstr, newstr );
}
}
Return text;
}
// Interaction. MsgBox ("no Chinese characters entered", MsgBoxStyle. OkOnly, null );
Return text;
}
Public string TranToSimple (string text) // convert to simplified.
{
If (text. ToString (). Length> 0)
{
String Sstr = Conversions. ToString (this. getSimple ());
String Tstr = Conversions. ToString (this. getTrade ());
Char [] simpleArr = Sstr. ToCharArray (0, Sstr. Length-1 );
Int VB $ t_i4 $ L0 = text. Length-1;
For (int I = 0; I <= VB $ t_i4 $ L0; I ++)
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.