ASCII or ANSI with Unicode (UTF-16)

348 Views Asked by At

I am a very stupid Programme Manager and I have a client requesting us to send in either ASCII or ANSI encoding format.

Our programmers has used Unicode (UTF-16), so my question is if Unicode (UTF-16) is compatible with ASCII or ANSI? Or am I understanding this incorrectly? Are we to change encoding or?

We haven't tried anything yet.

1

There are 1 best solutions below

1
Doug Moore On

In short: ASCII encoding contains 128 characters. ANSI encoding contains 256 characters. UTF-16 encoding has the capacity for 1,112,064 character codes. There is some nuance such as the bytes used to store each character, but I don't think that is relevant here.

You can certainly convert a UTF-16 document down to ANSI or ASCII encoding, but any characters that are beyond their specification will be lost (probably converted to the 128th or 256th character, respectively, or some sort of null character).

For you, as a manager, there are some questions. At minimum:

  1. Why does the client need this particular encoding? Can it be accommodated in some other way?
  2. Are any characters in your data beyond the scope of ASCII/ANSI. Most (all?) programming languages provide a method to retrieve an integer representation of a character and determine if it is beyond the range of the desired encoding. This could be leveraged to discover how many instances exist of a character not compatible with the desired encoding.