Difference Between UTF-8 and UTF-16
UTF stands for Unicode Transformation Format. It is a family of standards for encoding the Unicode character set into its equivalent binary value. UTF was developed so that users have a standardized means of encoding the characters with the minimal amount of space.UTF-8 and UTF 16 are only two of the established standards for encoding. They only differ in how many bytes they use to encode each character. Since both are variable width encoding, they can use up to four bytes to encode the data but when it comes to the minimum, UTF-8 only uses 1 byte (8bits) and UTF-16 uses 2 bytes(16bits). This bears a huge impact on the resulting size of the encoded files. When using ASCII only characters, a UTF-16 encoded file would be roughly twice as big as the same file encoded with UTF-8.
The main advantage of UTF-8 is that it is backwards compatible with ASCII. The ASCII character set is fixed width and only uses one byte. When encoding a file that uses only ASCII characters with UTF-8, the resulting file would be identical to a file encoded with ASCII. This is not possible when using UTF-16 as each character would be two bytes long. Legacy software that is not Unicode aware would be unable to open the UTF-16 file even if it only had ASCII characters.
UTF-8 is byte oriented format and therefore has no problems with byte oriented networks or file. UTF-16, on the other hand, is not byte oriented and needs to establish a byte order in order to work with byte oriented networks. UTF-8 is also better in recovering from errors that corrupt portions of the file or stream as it can still decode the next uncorrupted byte. UTF-16 does the exact same thing if some bytes are corrupted but the problem lies when some bytes are lost. The lost byte can mix up the following byte combinations and the end result would be garbled.
Summary:
1. UTF-8 and UTF-16 are both used for encoding characters
2. UTF-8 uses a byte at the minimum in encoding the characters while UTF-16 uses two
3. A UTF-8 encoded file tends to be smaller than a UTF-16 encoded file
4. UTF-8 is compatible with ASCII while UTF-16 is incompatible with ASCII
5. UTF-8 is byte oriented while UTF-16 is not
6. UTF-8 is better in recovering from errors compared to UTF-16
- Difference Between Sony Cybershot S Series and W Series - December 22, 2012
- Difference Between Samsung Galaxy S3 and iPhone 5 - December 21, 2012
- Difference Between Samsung Galaxy S2 (Galaxy S II) and Galaxy S 4G - December 20, 2012
Search DifferenceBetween.net :
Email This Post : If you like this article or our site. Please spread the word. Share it with your friends/family.
Wow, this is really informative! I have a question. Is there any quality difference between 8 and 16? Like if it is a sound file or an image.
As sound-files or images are binary-data they contain there own “encoding” aka a algorithm which stores the specific data.
UTF-x is for encoding characters of alphabets. So if you open a data-file in your texteditor you see a different flavor of gibberish, depending whether you use 8 or 16 😉
If one wants to see whats in such files there is a slim chance of seeing something useful with a hex-editor.
Very good article. thank you very much. i was looking for a such article for a while
Something I don’t understand… UTF-8 is 8 bits, meaning it can only display 255 different characters. What about all the Asian, Russian, Hebrew etc. symbols? 255 is not enough to hold them. How is this done? Do I have to use UTF-16 for these languages?
UTF-8 is minimum 8 bits (not just 8 bits) and hence can handle non ASCII chars as well.
Good article.
My long-time confusion is solved now 😛
Hmm. So why would anybody bother to use utf-16?