Re: how to get rid of a character, 0x80?

2009-09-08 Thread Gary Kline
On Tue, Sep 08, 2009 at 08:02:06AM -0500, Jim White wrote:
> On Tue, Sep 8, 2009 at 7:43 AM, Jon Radel  wrote:
> 
> > Mark Stapper wrote:
> >
> >  besides.. 0x80!=0200
> >> it's 0200 octal which is 128 decimal...
> >> Might be why it doesn't work for you.
> >>
> >
> > Don't mess with his head.  ;-)
> >
> > 0200 = 0x80 = 128
> >
> > 200 octal = 80 hex = 128 decimal
> >

Yup :-)
> >
> > --Jon Radel
> > j...@radel.com
> >
> 
> You may want to check if your char type is signed.  If it is (and it just
> happens to be 8 bits wide), (char)128 is a negative value.


I used 

int ch, not char ch;

Also, just found some throwaway code that [of course] never gets 
pitched, and
found the for chars >= 128, it's a wide character.   



while (( ch = getwc(stdin)) != WEOF)
{

if (ch == L'\xe2')
{
if ((ch1 = getwc(stdin)) == L'\x80')
{
printf("'");


/* check for and swallow last of the 
trio */
if ((ch2 = getwc(stdin)) == L'\x90')
{
continue;
}
}
}
else
{
putchar (ch);
}
}


I wrote the above to get rid of openoffice TXT that was still cluttered 
with the
trio of wide characters that output one apostrophe.

Last night I used pdftotext to translate a pdf file; it was cluttered 
with a slew of
^L's, which == '\014', and wound up with a greater slew of  in 
more [less]
and vi.  Nutshell, the file was fubar'd.

gary





-- 
 Gary Kline  kl...@thought.org  http://www.thought.org  Public Service Unix
http://jottings.thought.org   http://transfinite.thought.org
The 5.67a release of Jottings: http://jottings.thought.org/index.php

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: how to get rid of a character, 0x80?

2009-09-08 Thread Jim White
On Tue, Sep 8, 2009 at 7:43 AM, Jon Radel  wrote:

> Mark Stapper wrote:
>
>  besides.. 0x80!=0200
>> it's 0200 octal which is 128 decimal...
>> Might be why it doesn't work for you.
>>
>
> Don't mess with his head.  ;-)
>
> 0200 = 0x80 = 128
>
> 200 octal = 80 hex = 128 decimal
>
> --
>
> --Jon Radel
> j...@radel.com
>

You may want to check if your char type is signed.  If it is (and it just
happens to be 8 bits wide), (char)128 is a negative value.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: how to get rid of a character, 0x80?

2009-09-08 Thread Jon Radel

Mark Stapper wrote:


besides.. 0x80!=0200
it's 0200 octal which is 128 decimal...
Might be why it doesn't work for you.


Don't mess with his head.  ;-)

0200 = 0x80 = 128

200 octal = 80 hex = 128 decimal

--

--Jon Radel
j...@radel.com


smime.p7s
Description: S/MIME Cryptographic Signature


Re: how to get rid of a character, 0x80?

2009-09-08 Thread Bertram Scharpf
Hi,

Am Dienstag, 08. Sep 2009, 08:00:27 +0200 schrieb Mark Stapper:
> Gary Kline wrote:
> > anybody know why getchar() doesn't see 0x80 == 0200?
> 
> Presumably, you want to read a capital C with cedille? (0x80 128 Ç)

"\x80" is a nonbreakable space in iso8859-1/-15.
(And a Euro sign in Windows-1252). Who uses cp437/cp850 on BSD?

> besides.. 0x80!=0200

  $ ruby -e 'puts 0x80, 0200'
  128
  128

Bertram


-- 
Bertram Scharpf
Stuttgart, Deutschland/Germany
http://www.bertram-scharpf.de
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: how to get rid of a character, 0x80?

2009-09-07 Thread Mark Stapper
Gary Kline wrote:
>   anybody know why getchar() doesn't see 0x80 == 0200?  if getchar()
>   is limited to 7-bit characters, what then?
>
>   % od -c file 
>
>   shows me that every character fits into 8 bits, so getwchar() is the 
> next thing.
>   but doesn't getwchar grab wide-chars only: 16 bits?
>
>   tia, guys,
>
>   gary
>
>
>
>   
Hello,

First of, this isn't really a BSD question.
Second, if you have an example code we might be able to help.
Presumably, you want to read a capital C with cedille? (0x80 128 Ç)
Example from: http://www.cplusplus.com/reference/clibrary/cstdio/getchar/
compiled on FreeBSD 7.2 with gcc 4.2.1 output:
"
Enter text. Include a dot ('.') in a sentence to exit:
sfeo
sfeo
Çsdfa
Çsdfa
"
besides.. 0x80!=0200
it's 0200 octal which is 128 decimal...
Might be why it doesn't work for you.
Greetz,
Mark



signature.asc
Description: OpenPGP digital signature


how to get rid of a character, 0x80?

2009-09-07 Thread Gary Kline

anybody know why getchar() doesn't see 0x80 == 0200?  if getchar()
is limited to 7-bit characters, what then?

% od -c file 

shows me that every character fits into 8 bits, so getwchar() is the 
next thing.
but doesn't getwchar grab wide-chars only: 16 bits?

tia, guys,

gary



-- 
 Gary Kline  kl...@thought.org  http://www.thought.org  Public Service Unix
http://jottings.thought.org   http://transfinite.thought.org
The 5.67a release of Jottings: http://jottings.thought.org/index.php

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"