UTF-8 or Default Unicode - Which one should be taken

J

Jazper

hi

i'd like to save a textfile within my program.
i read that ascii or ansi not should be taken anymore for storing textdata
to a file. people should take unicode encoding.
so with .net i can easely use...

System.Text.Encoding.Unicode
or
System.Text.Encoding.UTF-8

so which one should i take to be up to date? Unicode or UTF-8?

cheers, jazper
 
J

Jon Skeet [C# MVP]

Jazper said:
i'd like to save a textfile within my program.
i read that ascii or ansi not should be taken anymore for storing textdata
to a file. people should take unicode encoding.
so with .net i can easely use...

System.Text.Encoding.Unicode
or
System.Text.Encoding.UTF-8

so which one should i take to be up to date? Unicode or UTF-8?

You can use either. Both encode the same range of values. UTF-8 is more
compact if you've got a lot of ASCII text in your data, and Unicode is
more compact if you've got a lot of far East characters. Unicode might
also be simpler in some ways as it's a fixed width encoding (i.e. you
know that 1000 bytes is 500 characters - in UTF-8 it could be anything
from 250 to 1000 characters.)

Personally I prefer UTF-8 in most circumstances, but it does depend on
exactly what you want to do.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top