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