Compilation error with backslash
Hi,
While compiling my file in VC++, I get the errors listed below with reference to the following line of code -
wsprintf( szDesc,L"DSN=%s\xFF Database=MyDataBase Server\xFF Description=MyDataBase MyData MySource\xFF Server=%s\xFF Trusted_Connection=yes\xFF \xFF ",szDSNName,strServer);
Error -
error C2002: invalid wide-character constant
My project settings have UNICODE for pre-processor directives. My user locale and default locale are both Japanese while my OS is English.
The backslash character appears as a yen symbol in my file.
The same file compiles without issues on another machine in our group.
Can someone please explain what could be the reason ?
Thanks.
Re: Compilation error with backslash
I think that the problem is the \xFF which does not map to an unicode character but an extended ASCII character.
You should probably use \xFFFF or \x00FF
Re: Compilation error with backslash
Thanks for the advice.
Can you please guess what the author of the code (it is a code which I am trying to maintain) is trying to do by using \xFF ?
Is he trying to use "xFF" as a string or something ? Have not been able to figure out.
Re: Compilation error with backslash
Quote:
Originally Posted by humble_learner
Thanks for the advice.
Can you please guess what the author of the code (it is a code which I am trying to maintain) is trying to do by using \xFF ?
Is he trying to use "xFF" as a string or something ? Have not been able to figure out.
\xFF is replaced by the ASCII character with value FF (=255). This is probably used as a kind of delimiter.
You can find the ASCII codes here: http://www.lookuptables.com/
Re: Compilation error with backslash
I checked up the look up table and the Extended ASCII codes seem to indicate that 255 is space (as per the link you have give me). Why has the author taken the trouble to indicate space as \xFF when he could simple have included a space character directly ?
Re: Compilation error with backslash
Quote:
Originally Posted by humble_learner
I checked up the look up table and the Extended ASCII codes seem to indicate that 255 is space (as per the link you have give me). Why has the author taken the trouble to indicate space as \xFF when he could simple have included a space character directly ?
That is not correct. The symbol 255 is a white square. Unfortunately the background color of the web site is also white, so it looks empty.
BTW: Space has number 32 (0x20)
Re: Compilation error with backslash
try \x00ff. No guarantees, but the compiler might interpret four digits as a wide character.
Note that there is a potential "gotcha" using hex escape sequences - the standard says that there is no limit on the number of hex digits, so strings like "followed by\x0Da new line" will not do what you might expect. (It will try to put in the character '\x0da', not '\x0d', 'a')
Re: Compilation error with backslash
character 255 in the extended ASCII table is the "espace inséquable" (I don't know the english name).
Two words delimited by an "espace inséquable" cannot appear on a different line.