Click here to Skip to main content
15,446,510 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
hii
plz can help me
i need code in c# to convert text to UTF8?
Posted
Updated 28-Apr-11 8:18am
v2

Rich brought my attention to the word: "convert text to UTF8".

To me, it is some indication of the fact that you need to get some understanding on how Unicode works and what the UTFs are. Just a hint: many said Unicode is a 16-bit code. This is not true. Actually, the number of code points is much more than that and each and every UTF (even UTF-16 :-), what a paradox) support them all at the same time.

Therefore, it is important to get introduced to http://unicode.org/[^].

See also:
http://www.unicode.org/faq//utf_bom.html[^].

—SA
 
Share this answer
 
Comments
Manfred Rudolf Bihy 28-Apr-11 17:41pm    
Go to the source, yes! 5+
Sergey Alexandrovich Kryukov 28-Apr-11 21:00pm     CRLF
Thank you, Manfred. --SA
Ed Nutting 28-Apr-11 17:46pm    
Agreed with Manfred. My 5 :)
Sergey Alexandrovich Kryukov 28-Apr-11 21:00pm     CRLF
Thank you. --SA
VB
System.Text.Encoding utf_8 = System.Text.Encoding.UTF8;

string s = "unicode";

//string to utf
byte[] utf = System.Text.Encoding.UTF8.GetBytes(s);

//utf to string
string s2= System.Text.Encoding.UTF8.GetString(utf);




Good luck in the future.
 
Share this answer
 
v3
Comments
Ed Nutting 28-Apr-11 14:46pm    
Now you've done it for him/her they won't learn, great :)
velvet7 28-Apr-11 14:52pm    
While I am not fed up of them I try to help them out, anyway you are right, maybe this isn't the best way to do that.
Ed Nutting 28-Apr-11 14:55pm    
Thank you :)
Marc A. Brown 28-Apr-11 15:02pm    
I think my answer would've been somewhere between yours and EdMan's. No code, but tell the OP to look at System.Text.Encoding. That way I'd provide some info but force him or her to do some research. In any event, have a 5 for the answer.
Albin Abel 28-Apr-11 16:00pm    
I agree with you. My 5 shared between the solution and the comments.
Did you try searching? A simple search will get you the answer to this.

P.S. I just did it myself and got the answer very quickly...
 
Share this answer
 
v2
Comments
velvet7 28-Apr-11 14:42pm    
Don't be so evil:)
Ed Nutting 28-Apr-11 14:45pm    
We get fed up of people not bothering to search or try anything and just posting lazy questions on CP that don't really make them leanr. We are not here to do your work for you! ;P
Nish Nishant 28-Apr-11 15:46pm    
My vote of 5! Sometimes this sort of thing just needs to be said!
Albin Abel 28-Apr-11 16:01pm    
My 5
Sergey Alexandrovich Kryukov 28-Apr-11 16:40pm     CRLF
This is not evil! From the other hand, even though I voted 5, I know that there is a lot of misleading information on Unicode on the Web. Therefore, I decided to post the orthodox kosher karmic canonical references on the topic :-) Please see my answer. --SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900