PC Review


Reply
Thread Tools Rate Thread

How to display international characters?

 
 
=?Utf-8?B?TXJOb2JvZHk=?=
Guest
Posts: n/a
 
      7th Jan 2005
I'm loading some names from a file which contains many names, some of which
have some international charcaters like: ö

When I load these names and put them into GUI Labels or DataGrid columns
those characters turn into a question mark, so instead of seeing 'Böhme' I
see 'B?hme'...

any idea why?
 
Reply With Quote
 
 
 
 
=?Utf-8?B?TXJOb2JvZHk=?=
Guest
Posts: n/a
 
      7th Jan 2005
Actually, I went to double check and it's not the UI controls that are the
problem... the string has got a question mark character as soon as I load
from the file. I read the file like this:

using (StreamReader sr = new StreamReader(file.OpenRead(), Encoding.ASCIi)) {
string line = sr.ReadLine();
// etc ...
}

and right away, I see the question mark in 'line' instead of the right
character

what am I doing wrong?
 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      7th Jan 2005
Mr Nobody,

The reason is probably that the language or regional settings of your
workstation do not have the codetable wherein that file is written. To
change that in your computer is only a temporaly solution for you.

Better is to find out how that file is written and than read it with the
encoding.
http://msdn.microsoft.com/library/de...classtopic.asp

(When you think nothing works do than not forget to the method
"getencoding").

I hope this helps?

Cor

"MrNobody" <(E-Mail Removed)>


> I'm loading some names from a file which contains many names, some of
> which
> have some international charcaters like: ö
>
> When I load these names and put them into GUI Labels or DataGrid columns
> those characters turn into a question mark, so instead of seeing 'Böhme' I
> see 'B?hme'...
>
> any idea why?



 
Reply With Quote
 
Mattias Sjögren
Guest
Posts: n/a
 
      7th Jan 2005

>using (StreamReader sr = new StreamReader(file.OpenRead(), Encoding.ASCIi)) {

[...]
>what am I doing wrong?


You're using the ASCII encoding when reading the file, which doesn't
support these characters. You have to use an encoding that matches how
the file was originally written, most likely Encoding.Default or UTF8.



Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
 
Reply With Quote
 
=?Utf-8?B?TXJOb2JvZHk=?=
Guest
Posts: n/a
 
      7th Jan 2005
OK I tried Encoding.Default and it loaded the characters without a problem,
but then when I tried to write the file using Encoding.Default it put those
question marks in the file (I viewed the file with Word and Excel)

"Mattias Sjögren" wrote:

>
> >using (StreamReader sr = new StreamReader(file.OpenRead(), Encoding.ASCIi)) {

> [...]
> >what am I doing wrong?

>
> You're using the ASCII encoding when reading the file, which doesn't
> support these characters. You have to use an encoding that matches how
> the file was originally written, most likely Encoding.Default or UTF8.
>
>
>
> Mattias
>
> --
> Mattias Sjögren [MVP] mattias @ mvps.org
> http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
> Please reply only to the newsgroup.
>

 
Reply With Quote
 
Kai Brinkmann [MSFT]
Guest
Posts: n/a
 
      7th Jan 2005
Encoding.Default uses the system's current ANSI code page. If a character
cannot be represented using this code page (as seems to be the case here),
you end up with a question mark. To make sure that you can accurately
represent all characters, you should use Encoding.UTF8 or Encoding.Unicode.
--
Kai Brinkmann [MSFT]

Please do not send e-mail directly to this alias. This alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


"MrNobody" <(E-Mail Removed)> wrote in message
news:A48992B7-AAF5-4F74-BAD7-(E-Mail Removed)...
> OK I tried Encoding.Default and it loaded the characters without a
> problem,
> but then when I tried to write the file using Encoding.Default it put
> those
> question marks in the file (I viewed the file with Word and Excel)
>
> "Mattias Sjögren" wrote:
>
>>
>> >using (StreamReader sr = new StreamReader(file.OpenRead(),
>> >Encoding.ASCIi)) {

>> [...]
>> >what am I doing wrong?

>>
>> You're using the ASCII encoding when reading the file, which doesn't
>> support these characters. You have to use an encoding that matches how
>> the file was originally written, most likely Encoding.Default or UTF8.
>>
>>
>>
>> Mattias
>>
>> --
>> Mattias Sjögren [MVP] mattias @ mvps.org
>> http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
>> Please reply only to the newsgroup.
>>



 
Reply With Quote
 
=?Utf-8?B?TXJOb2JvZHk=?=
Guest
Posts: n/a
 
      7th Jan 2005
Thanks for your reply!

I tried using Unicode, and everytihng just broke (The lines it reads is just
filled with boxes- no recognizeable characters) With UTF8 it loaded the file
but then instead of putting question marks it actually REMOVED the
international characters!


"Kai Brinkmann [MSFT]" wrote:

> Encoding.Default uses the system's current ANSI code page. If a character
> cannot be represented using this code page (as seems to be the case here),
> you end up with a question mark. To make sure that you can accurately
> represent all characters, you should use Encoding.UTF8 or Encoding.Unicode.
> --
> Kai Brinkmann [MSFT]
>
> Please do not send e-mail directly to this alias. This alias is for
> newsgroup purposes only.
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
International characters jyazelz@peoplepc.com Printers 17 13th Jun 2011 01:25 AM
international characters in url Peter Kirk Microsoft C# .NET 4 15th Aug 2006 08:32 AM
international characters =?Utf-8?B?ZGF2ZQ==?= Windows XP New Users 1 5th Oct 2005 01:42 PM
International characters Mark Windows XP General 2 22nd Jan 2004 05:27 AM
international characters Annemie Windows XP Video 0 5th Sep 2003 09:24 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:36 PM.