|
-
March 1st, 2006, 07:36 AM
#1
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.
-
March 1st, 2006, 07:44 AM
#2
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
"inherit to be reused by code that uses the base class, not to reuse base class code", Sutter and Alexandrescu, C++ Coding Standards.
Club of lovers of the C++ typecasts cute syntax: Only recorded member.
Out of memory happens! Handle it properly!
Say no to g_new()!
-
March 1st, 2006, 07:53 AM
#3
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.
-
March 1st, 2006, 08:01 AM
#4
Re: Compilation error with backslash
 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/
Please don't forget to rate users who helped you!
-
March 1st, 2006, 08:08 AM
#5
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 ?
-
March 1st, 2006, 08:29 AM
#6
Re: Compilation error with backslash
 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)
Please don't forget to rate users who helped you!
-
March 1st, 2006, 10:29 AM
#7
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')
Correct is better than fast. Simple is better than complex. Clear is better than cute. Safe is better than insecure.
-- Sutter and Alexandrescu, C++ Coding Standards
Programs must be written for people to read, and only incidentally for machines to execute.
-- Harold Abelson and Gerald Jay Sussman
The cheapest, fastest and most reliable components of a computer system are those that aren't there.
-- Gordon Bell
-
March 1st, 2006, 12:00 PM
#8
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.
"inherit to be reused by code that uses the base class, not to reuse base class code", Sutter and Alexandrescu, C++ Coding Standards.
Club of lovers of the C++ typecasts cute syntax: Only recorded member.
Out of memory happens! Handle it properly!
Say no to g_new()!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|