473,387 Members | 1,603 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to display international characters?

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?
Nov 16 '05 #1
6 2650
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?
Nov 16 '05 #2
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" <Mr******@discussions.microsoft.com>

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?

Nov 16 '05 #3
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.
Nov 16 '05 #4
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.

Nov 16 '05 #5
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" <Mr******@discussions.microsoft.com> wrote in message
news:A4**********************************@microsof t.com...
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.

Nov 16 '05 #6
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.


Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ruslan Popov | last post by:
Hello, Is there a way to change encoding of a message created with CDO.Message, or otherwise send international characters (unicode) in Textbody? The messages I get now show question signs...
4
by: SB | last post by:
Hi, I'd like to display some non-ascii characters in a DOS window. I'm getting the characters from Windows Character Map, such as the Spade (U+2660) and a few others. However, I can't get it to...
15
by: Steve | last post by:
Hi, I've been charged with investigating the possibilities of internationalizing our C++ libraries. std::strings are used all over the place, and unfortunately a mixture of...
12
by: laurenq uantrell | last post by:
Is there an easy way to loop through all rows and remove all international alphabet characters from a column in a table, for example remove German umlauts "ü" and convert them to a simple "u"....
3
by: Marauderz | last post by:
Hello guys, got a little question regarding the regional language settings . Anyway I got a Windows 2003 Server machine that was installed with the date format "dd/MM/yyyy" and location still...
1
by: Andreas R. | last post by:
Hello, When parsing XML documents containing international characters, such as the Norwegian characters Æ, Ø, Å, I get an exception in Python's SAX module. What is the correct way to parse such...
1
by: Peter K | last post by:
Hi I am writing an application where I need to process some text read from files, and write information to a content-management-system. Unfortunately the CMS does not accept international...
0
Logan1337
by: Logan1337 | last post by:
Hi. I'm writing an RSS reader and have just discovered it doesn't work with international characters. I'm handling UTF-8 just fine and can handle extended "special" characters, like accents and so...
0
by: Elmo Watson | last post by:
I'm trying an example in the ASP.Net unleashed book, using a Treeview and an XML file The XML file came from a spit-out (for xml) of a query in the Northwind database, giving me Categories and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.