Solved

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

Posted on 2004-09-17
5
438 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

719 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