Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Shift-JIS to UTF-8 Conversion C# source code sample program demonstrating how to convert Shift-JIS Japanese character data to utf-8. private void button1_Click(object sender, System.EventArgs e)
{
Chilkat.Charset cc = new Chilkat.Charset();
cc.UnlockComponent("Anything begins 30-day trial");
// Read Shift-JIS text from a file.
System.IO.FileInfo fInfo = new System.IO.FileInfo("shiftJisSample.txt");
System.IO.BinaryReader br = new System.IO.BinaryReader(
System.IO.File.OpenRead("shiftJisSample.txt"));
byte [] shiftJisBytes = br.ReadBytes((int)fInfo.Length);
br.Close();
// Convert from Shift-JIS to utf-8
cc.ToCharset = "utf-8";
cc.FromCharset = "Shift_JIS";
byte [] utf8Bytes = cc.ConvertData(shiftJisBytes);
// Write the output file in Shift-JIS
System.IO.BinaryWriter bw = new System.IO.BinaryWriter(
System.IO.File.Create("utf8Sample.txt"));
bw.Write(utf8Bytes);
bw.Close();
}
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2008 Chilkat Software, Inc. All Rights Reserved.