Using System;
Using System. Collections. Generic;
Using System. text;
// Add Microsoft Visual Basic. Net runtime reference.
Using Microsoft. VisualBasic;
Using System. IO;
Namespace Simpletotraditional
{
Class Exchangechinese
{
/// <Summary>
/// Convert string to simplified Chinese
/// </Summary>
Public Static String Tosimplifiedchinese ( String S)
{
Return Strings. strconv (S, vbstrconv. simplifiedchinese, 0 );
}
/// <Summary>
/// Convert string to traditional Chinese
/// </Summary>
Public Static String Totraditionalchinese ( String S)
{
Return Strings. strconv (S, vbstrconv. traditionalchinese, 0 );
}
/// <Summary>
/// Convert files to simplified Chinese
/// </Summary>
/// <Param name = "FILENAME"> Source File Name </Param>
/// <Param name = "outfilename"> Target file name </Param>
Public Static Void Tosimplifiedchinese ( String Filename, String Outfilename)
{
Streamreader R = New Streamreader (filename, encoding. getencoding ( " Gb2312 " ));
Streamwriter W = New Streamwriter (outfilename, False , Encoding. getencoding ( " Gb2312 " ));
Try
{
W. Write (strings. strconv (R. readtoend (), vbstrconv. simplifiedchinese, 0 ));
W. Flush ();
}
Finally
{
W. Close ();
R. Close ();
}
}
/// <Summary>
/// Convert files to traditional Chinese
/// </Summary>
/// <Param name = "FILENAME"> Source File Name </Param>
/// <Param name = "outfilename"> Target file name </Param>
Public Static Void Totraditionalchinese ( String Filename, String Outfilename)
{
Streamreader R = New Streamreader (filename, encoding. getencoding ( " Gb2312 " ));
Streamwriter W = New Streamwriter (outfilename, False , Encoding. getencoding ( " Gb2312 " ));
Try
{
W. Write (strings. strconv (R. readtoend (), vbstrconv. traditionalchinese, 0 ));
W. Flush ();
}
Finally
{
W. Close ();
R. Close ();
}
}
}
}