Note that there are some explanatory texts on larger screens.

plurals
  1. POHow does WChar relate to Unicode and ASCII
    primarykey
    data
    text
    <p>I am about to show my total ignorance of how encoding works and different string formats.</p> <p>I am passing a string to a compiler (Microsoft as it happens amd for their Flight Simulator). The string is passed as part of an XML document which is used as the source for the compiler. This is created using using standard NET strings. I have not needed to specifically specify any encoding or setting of type since the XML is just text.</p> <p>The string is just a collection of characters. This is an example of one that gives the error:</p> <p>ARG, AFL, AMX, ACA, DAH, CCA, AEL, AGN, MAU, SEY, TSC, AZA, AAL, ANA, BBC, CPA, CAL, COA, CUB, DAL, UGX, ELY, UAE, ERT, ETH, EEZ, GHA, IRA, JAL, NWA, KAL, KAC, LAN, LDI, MAS, MEA, PIA, QTR, RAM, RJA, SVA, SIA, SWR, ROT, THA, THY, AUI, UAL, USA, ACA, TAR, UZB, IYE, QFA</p> <p>If I create the string using my C# managed program then there is no issue. However this string is coming from a c++ program that can create the compiled file using its own compiler that is not compliant with the MS one</p> <p>The MS compiler does not like the string. It throws two errors:</p> <p>INTERNAL COMPILER ERROR: #C2621: Couldn't convert WChar string! INTERNAL COMPILER ERROR: #C2029: Failed to convert attribute value from UNICODE!</p> <p>Unfortunately there is not any useful documentation with the compiler on its errors. We just makethe best of what we see!</p> <p>I have seen other errors of this type but these contain hidden characters and control characters that I can trap and remove.</p> <p>In this case I looked at the string as a Char[] and could not see anything unusual. Only what I expected. No values above the ascii limit of 127 and no control characters.</p> <p>I understand that WChar is something that C++ understands (but I don't), Unicode is a two byte representation of characters and ASCII is a one byte representation.</p> <p>I would like to do two things - first identify a string that will fail if passed to the compiler and second fix the string. I assume the compiler is expecting ASCII.</p> <p>EDIT</p> <p>I told an untruth - in fact I do use encoding. I checked the code I used to convert a byte array into a string.</p> <pre><code>public static string Bytes2String(byte[] bytes, int start, int length) { string temp = Encoding.Defaut.GetString(bytes, start, length); } </code></pre> <p>I realized that Default might be an issue but changing it to ASCII makes no difference. I am beginning to believe that the error message is not what it seems.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload