Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello to everyone!!

I'm new to this forum and is my first day with .NET...

 

I'm making an aplication to read a file, it's a binary file with some text is spanish, so it has some tildes and ñ.

The file is "wrong encoded" it is done with the "new" windows ASCII code.. I'll try to explain.

 

The ASCII code for "ú" is 163, for "é" 130, etc...

but in the windows Char Map the code for ú is 250 and for é is 233, the file is encoded this way with this annoying codepage.

 

I opened the file as a FileStream and use a BinaryReader object to read it.

Here is the problem, I want to convert those chars to their real value, I think it can be done with System.Text.Encoding.ASCII.GetChars but instead of ascii I get a "?".

Anyone can help me with this??

 

 

Here i will show you what i have tested:

'The string is "aécX"

'With this
Temp=r.ReadChars(3)
'I get Temp = "acX" 

'With this
Temp=Encoding.ASCII.GetChars(r.ReadBytes(3))
'I get Temp = "a?c" 

'I want to get Temp = "aéc"

 

--

Bye,

Ronq. ;)

Posted

How can i get the code page??

it isn't in the file im using, and also i think is a standart windows codepage, because for example the nfo files that uses the "bad boys", can't be read as well.

Posted (edited)

can you post the nfo file?

Did you try using the other methods like Encoding.Unicode, Encoding.UTF7 or Encoding.UTF8?

Edited by HJB417
Posted

It isn't an NFO file is a dat file from a palm program, it isn't unicode. I think it is this encoding "Windows operating system (windows-1252)", im going to try this.

Any more help is welcome.

 

Bye,

Ronq.

Posted

It was easyer than i tought i read the entire encoding namespace help to know that the Default encoding would work fine.

 

'The string is "aécX"

'With this
Temp=Encoding.Default.GetChars(r.ReadBytes(3))
'I get Temp = "aéc" 

 

Thanks, to HJB417 for your help!

 

bye,

Ronq.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...