5

Possible Duplicate:
UTF8, UTF16, and UTF32

I am always reading things saying to write my source code in UTF-8 and stay way from other encodings, but it also seems like UTF-16 is an improved version of UTF-8. What is the difference between them, and is there any advantage to either one?

Community
  • 1
  • 1
Orcris
  • 3,135
  • 6
  • 24
  • 24
  • 3
    UTF-16 has ***all the disadvantages*** of both UTF-8 and of UTF-32 alike, while simultaneously enjoying ***none of the advantages of either.*** It’s the worst of both worlds, and the best of none. Use UTF-8 for storage and transfer; use UTF-32 for memory operations; and use UTF-16 for nothing. – tchrist Mar 07 '12 at 02:02
  • 3
    "use UTF-16 for nothing" ... except when interacting with APIs that require it, such as the Win32 API. – Remy Lebeau Mar 08 '12 at 01:51

1 Answers1

5

This should help :)

http://www.differencebetween.net/technology/difference-between-utf-8-and-utf-16/

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
Community
  • 1
  • 1
Michael
  • 807
  • 4
  • 14
  • 25
  • 7. With relaxed validation, all possible invalid UTF-16 can be round-tripped through UTF-8. The reverse does not hold. – Deduplicator Mar 04 '15 at 02:12