Solved

how to read unicode datas from mysql and save it to xml file?

Posted on 2004-09-17
5
404 Views
Last Modified: 2010-05-18
i can view the datas with php throught web pages. but when i try to read the data with C# and save to xml, it doesn't work :(
0
Comment
Question by:smantha1979
5 Comments
 
LVL 5

Expert Comment

by:tzxie2000
ID: 12093462
suggest the data you read from mysql is store in char[] sa and it is a UniCode

char [] sa;
string s

//some code to receive data in s or sa
//you can change s to sa by your demand

Encoder UniCodeEncoder = Encoding.UniCode.GetEncoder();

int byteCount = UniCodeEncoder.GetByteCount(s, 0, s.Length, true);
Byte[] bytes = new Byte[byteCount];
int bytesEncodedCount = UniCodeEncoder.GetBytes(s, 0,s.Length, bytes, 0, true);
//ok it change to UniCode
// bytesEncodedCount is the real changed bytes number
 Console.WriteLine("{0} bytes used to encode characters.", bytesEncodedCount );
//show the encoded bytes
Console.Write("Encoded bytes: ");
  foreach (Byte b in s) {
        Console.Write("[{0}]", b);
   }//the result is save in bytes

0
 

Author Comment

by:smantha1979
ID: 12094222
thankz for reply.
i found out that, its because of bytefx, bytefx depends on mysql's server character, and mysql uses latin, that's why it can't read when the character set doesn't match the default character set,, i give myself 250 points :)
0
 

Accepted Solution

by:
CetusMOD earned 0 total points
ID: 12436190
PAQed, with points refunded (250)

CetusMOD
Community Support Moderator
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now