BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

£ character

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Command Line Tools)
View previous topic :: View next topic  
Author Message
Québec
Guest





PostPosted: Thu Nov 23, 2006 6:26 am    Post subject: £ character Reply with quote



Hi gurus,

Can I ask the compiler to accept the £ character. It is a delimiter for a
parser. I use this character because I am sure there wont be in the file.


--
Thanks for your attention.

Jean Pierre Daviau
--
Easyphp1.8 with Apache1.3.24
DEVC++, borland 5.5
windows Xp
asus p4 s533/333/133
Intel(R) Celeron (R) CPU 2.00 GHz
Processor Radeon7000 0x5159 agp
Back to top
Alan Bellingham
Guest





PostPosted: Thu Nov 23, 2006 7:11 am    Post subject: Re: £ character Reply with quote



"Québec" <Once (AT) WasEno (DOT) ugh> wrote:

Quote:
Hi gurus,

Can I ask the compiler to accept the £ character. It is a delimiter for a
parser. I use this character because I am sure there wont be in the file.

I expect so - it's a pretty commonly used character in files that we
have.

(Since we deal with currency stuff.)

Why, did you think it wouldn't? It's just another character, like é.

Alan Bellingham
--
Team Thai Kingdom
<url:http://www.borland.com/newsgroups/> Borland newsgroup descriptions
<url:http://www.borland.com/newsgroups/netiquette.html> netiquette
Back to top
Québec
Guest





PostPosted: Thu Nov 23, 2006 9:10 am    Post subject: Re: £ character Reply with quote



There is none in the atrget files for sure.
The compiler complain character out of range.
Back to top
Alan Bellingham
Guest





PostPosted: Thu Nov 23, 2006 3:34 pm    Post subject: Re: £ character Reply with quote

"Québec" <Once (AT) WasEno (DOT) ugh> wrote:

Quote:
There is none in the atrget files for sure.
The compiler complain character out of range.

What function are you calling that causes this error?

Alan Bellingham
--
Team Thai Kingdom
<url:http://www.borland.com/newsgroups/> Borland newsgroup descriptions
<url:http://www.borland.com/newsgroups/netiquette.html> netiquette
Back to top
Québec
Guest





PostPosted: Thu Nov 23, 2006 6:59 pm    Post subject: Re: £ character Reply with quote

not a function really. The compiler did not complain here but the if is not
taken into acooount because for him there is no such a carachter. If I put
a ^ instead, everything goes fine.

while (--limit > 0 && (c = getc(fp)) != EOF) {
if (c != '£' && flag != 0) {
fputc(c, fpout);
continue;
}
Back to top
Alan Bellingham
Guest





PostPosted: Thu Nov 23, 2006 8:20 pm    Post subject: Re: £ character Reply with quote

"Québec" <Once (AT) WasEno (DOT) ugh> wrote:

Quote:
not a function really. The compiler did not complain here but the if is not
taken into acooount because for him there is no such a carachter. If I put
a ^ instead, everything goes fine.

while (--limit > 0 && (c = getc(fp)) != EOF) {
if (c != '£' && flag != 0) {
fputc(c, fpout);
continue;
}

Ah, it's top-bit-set character problems. getc() returns an unsigned
char, cast to int, so it will return something in the range 0-255, or
EOF

By default, '£' is a signed char under bcc32, so the value you'd be
comparing against wouldn't be 163, but would actually be -93.

Solution 1: use the -K compilation option - this tells bcc32 to use
unsigned chars

Solution 2: cast the '£' to be an unsigned char:

if (c != static_cast<unsigned char>('£') && ...

Alan Bellingham
--
ACCU Conference: 11-14 April 2007 - Paramount Oxford Hotel
Back to top
Québec
Guest





PostPosted: Sat Nov 25, 2006 8:33 pm    Post subject: Re: £ character Reply with quote

Quote:
Solution 1: use the -K compilation option - this tells bcc32 to use
unsigned chars
Alan Bellingham

Is this equivalent to
coding:iso-8859-1 ?
Back to top
Rudy Velthuis [TeamB]
Guest





PostPosted: Sat Nov 25, 2006 8:43 pm    Post subject: Re: character Reply with quote

At 15:33:09, 25.11.2006, Qubec wrote:

Quote:

Solution 1: use the -K compilation option - this tells bcc32 to use
unsigned chars
Alan Bellingham

Is this equivalent to
coding:iso-8859-1 ?

No. It simply defines how C++ treats chars, i.e. as signed or unsigned
(i.e. whether a top-bit is treated as 163 or as -93). It has nothing to
do with the actual encoding.

An encoding, like ISO-8859-1 defines which character gets which code.

http://en.wikipedia.org/wiki/Iso-8859-1
http://en.wikipedia.org/wiki/ISO-8859-15

--
Rudy Velthuis [TeamB] http://rvelthuis.de/

"I think it would be a good idea."
-- Mahatma Gandhi (1869-1948), when asked what he thought of
Western civilization
Back to top
Rudy Velthuis [TeamB]
Guest





PostPosted: Sat Nov 25, 2006 8:48 pm    Post subject: Re: character Reply with quote

At 15:43:14, 25.11.2006, Rudy Velthuis [TeamB] wrote:

Quote:
At 15:33:09, 25.11.2006, Qubec wrote:


Solution 1: use the -K compilation option - this tells bcc32 to use
unsigned chars
Alan Bellingham

Is this equivalent to
coding:iso-8859-1 ?

No. It simply defines how C++ treats chars, i.e. as signed or unsigned
(i.e. whether a top-bit is treated as 163 or as -93). It has nothing to
do with the actual encoding.

An encoding, like ISO-8859-1 defines which character gets which code.

http://en.wikipedia.org/wiki/Iso-8859-1
http://en.wikipedia.org/wiki/ISO-8859-15

FWIW, in C, you should have a look at setlocale, which defines the
charset and the collation options.

--
Rudy Velthuis [TeamB] http://rvelthuis.de/

"He is one of those people who would be enormously improved by
death." -- H. H. Munro (Saki) (1870-1916)
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Command Line Tools) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.