ASCII encoding and character sets... 
Author Message
 ASCII encoding and character sets...

I'm also having problems with special characters on an ASCII files.

I create the StreamReader that reads the file this way:

StreamReader stream = new StreamReader(fileName, new ASCIIEncoding());

The number of characters read is correct but every time a letter has
some kind of accentuation, it shows a question mark or some wierd
sentence. Is it possible to set the ASCII character set on the
StreamReader? Particularly for Portuguese characters...

Unfortunately the file I'm trying to read is generated by another
software package...

Thanks in advance...



Fri, 21 May 2004 13:52:23 GMT  
 ASCII encoding and character sets...
ASCII is the first 128 bytes of the massive Unicode library.  Thus, by using
ASCIIEncoding, you are throwing away half of the information on each
character.  For me, living in the USA, that's usually not a problem.  But,
to get Portuguese characters, you should be using the UnicodeEncoding class,
NOT the ASCIIEncoding class.

Now, how you get the Unicode in Portuguese, I hope someone else has the
answer to.  But, with Unicode characters, it should be a straightforward
process.


Quote:
> I'm also having problems with special characters on an ASCII files.

> I create the StreamReader that reads the file this way:

> StreamReader stream = new StreamReader(fileName, new ASCIIEncoding());

> The number of characters read is correct but every time a letter has
> some kind of accentuation, it shows a question mark or some wierd
> sentence. Is it possible to set the ASCII character set on the
> StreamReader? Particularly for Portuguese characters...

> Unfortunately the file I'm trying to read is generated by another
> software package...

> Thanks in advance...



Fri, 21 May 2004 15:27:22 GMT  
 ASCII encoding and character sets...

Quote:
> StreamReader stream = new StreamReader(fileName, new ASCIIEncoding());

> The number of characters read is correct but every time a letter has
> some kind of accentuation, it shows a question mark or some wierd
> sentence. Is it possible to set the ASCII character set on the
> StreamReader? Particularly for Portuguese characters...

I think what you want is setting the encoding on StreamReader
to an other encoding than ASCII. As you try process portuguese
text the required encoding is presumably UTF-8 or iso-8859-1.

For the latter try the following:
    System.Text.Encoding.GetEncoding("iso-8859-1")

--
Zoltan



Fri, 21 May 2004 22:01:46 GMT  
 ASCII encoding and character sets...
You will need to know which encoding (Code Page) the file is written
in to begin with.  That will depend on which encoding you use to read
the file.  You will find this site of particular interest:

http://www.microsoft.com/globaldev/

I believe however, if you use UTF-8 instead of ASCII, ,you should be
okay.  UTF-8 is optimised for single byte character sets , but can
handle multi byte characters with equal grace.

-- Gabe

On Mon, 3 Dec 2001 15:01:46 +0100, "Zoltan Sekeres [TRADOS]"

Quote:



>> StreamReader stream = new StreamReader(fileName, new ASCIIEncoding());

>> The number of characters read is correct but every time a letter has
>> some kind of accentuation, it shows a question mark or some wierd
>> sentence. Is it possible to set the ASCII character set on the
>> StreamReader? Particularly for Portuguese characters...

>I think what you want is setting the encoding on StreamReader
>to an other encoding than ASCII. As you try process portuguese
>text the required encoding is presumably UTF-8 or iso-8859-1.

>For the latter try the following:
>    System.Text.Encoding.GetEncoding("iso-8859-1")

>--
>Zoltan



Sat, 22 May 2004 09:16:10 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Changing Encoding /Character Set

2. TextBox, KeyEvent and High ASCII character set

3. Problem with a string which contains the ASCII character set

4. serial comms - byte transmission rather than ascii encoded

5. Encoding decoding what I think is ASCII/ECDB

6. ascii encoded hex to decimal conversion

7. special character problem - character sets?

8. Auto-delete message based on character encoding

9. Unicode character encoding

10. Converting encoded characters from Modem

11. XML and character encoding

12. UTF-8 encoding characters

 

 
Powered by phpBB® Forum Software