473,698 Members | 2,466 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

German Characters in textbox

Hi all,

When a user enters a german character in a textbox (such as ÷ ń Ř ▀) and I
try to save it, these characters get converted to a different character.
How can I prevent this?

Tia,
Martin

Jun 2 '07 #1
10 5564
Martin wrote:
Hi all,

When a user enters a german character in a textbox (such as ÷ ń Ř ▀) and
I try to save it, these characters get converted to a different
character. How can I prevent this?

Tia,
Martin
It sounds like it's a problem with encoding. You are probably either
using an encoding that doesn't support the characters, or using
different encodings for saving and retrieveing the text.

Where do you save it? Text file? Database? Left pocket?

Does the value change when you save it or when you retrieve it?

--
G÷ran Andersson
_____
http://www.guffa.com
Jun 2 '07 #2
Hi G÷ran,

Thanks for your reply. I'm saving the texts to a text (ascii) file. I'm not
using any special encoding, in fact I don't have any experience using other
character sets, so I am not aware of how to choose a special kind of
encoding... Any help would be greatly appreciated.

Tia,
Martin
"G÷ran Andersson" <gu***@guffa.co mwrote in message
news:ev******** ******@TK2MSFTN GP03.phx.gbl...
Martin wrote:
>Hi all,

When a user enters a german character in a textbox (such as ÷ ń Ř ▀) and
I try to save it, these characters get converted to a different
character. How can I prevent this?

Tia,
Martin

It sounds like it's a problem with encoding. You are probably either using
an encoding that doesn't support the characters, or using different
encodings for saving and retrieveing the text.

Where do you save it? Text file? Database? Left pocket?

Does the value change when you save it or when you retrieve it?

--
G÷ran Andersson
_____
http://www.guffa.com

Jun 2 '07 #3
Martin wrote:
Hi G÷ran,

Thanks for your reply. I'm saving the texts to a text (ascii) file. I'm not
using any special encoding, in fact I don't have any experience using other
character sets, so I am not aware of how to choose a special kind of
encoding... Any help would be greatly appreciated.
A file doesn't contain characters, it contains bytes, so every text file
uses some encoding to represent the characters as bytes.

The ASCII encoding doesn't support any special characters. You should
use the UTF-8 encoding. This is however the default for the methods in
the framework when you don't specify any encoding, so you have to have
done something to use some other encoding.

What does your code look like?

--
G÷ran Andersson
_____
http://www.guffa.com
Jun 2 '07 #4
Hi again,

The code Im using to read the file is I think pretty straightforward :

Private Sub DoOpenFile(ByVa l ThisFile As String)
Dim Line As String

Try
Dim sr As System.IO.Strea mReader = New
System.IO.Strea mReader(ThisFil e, True)
Line = sr.ReadLine()
sr.Close()
Catch Ex As Exception
MsgBox("Error reading file" & Chr(13) & Chr(13) & Ex.Message,
MsgBoxStyle.Cri tical Or MsgBoxStyle.OkO nly, "Error")
Exit Sub
End Try

Line = DoFormatLine(Li ne)
FillEditor(Line )
FileName = ThisFile
Editor.ReadOnly = False
Me.Text = "Editing " & FileName
End Sub

The text is created in an editor (MultiEdit) and looks like this:

FTX+AAK+1++Es bestehen Vereinbarungen, aus denen sich nachtr├Ągliche
Minderungen :des Entgelts ergeben k├Ânnen.+DE

When I open this in my app, it suddenly looks like this:

FTX+AAK+1++Es bestehen Vereinbarungen, aus denen sich nachtr´┐Żgliche
Minderungen :des Entgelts ergeben k´┐Żnnen.+DE

After your message I added the TRUE parameter in the streamreader (detect
encoding) and set the form's language to German... To no effect.

Tia,
Martin


"G├Âran Andersson" <gu***@guffa.co mwrote in message
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
Martin wrote:
>Hi G├Âran,

Thanks for your reply. I'm saving the texts to a text (ascii) file. I'm
not using any special encoding, in fact I don't have any experience using
other character sets, so I am not aware of how to choose a special kind
of encoding... Any help would be greatly appreciated.

A file doesn't contain characters, it contains bytes, so every text file
uses some encoding to represent the characters as bytes.

The ASCII encoding doesn't support any special characters. You should use
the UTF-8 encoding. This is however the default for the methods in the
framework when you don't specify any encoding, so you have to have done
something to use some other encoding.

What does your code look like?

--
G├Âran Andersson
_____
http://www.guffa.com
Jun 2 '07 #5
"Martin" <x@y.comschrieb :
Thanks for your reply. I'm saving the texts to a text (ascii) file.
ASCII is a 7-bit US encoding that doesn't support any umlauts.

Thus you have to use another encoding. 'StreamWriter' uses UTF-8 by default
which can contain umlauts. So, do not pass an ASCII encoding object to the
constructor.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jun 2 '07 #6
"Martin" <x@y.comschrieb :
The code Im using to read the file is I think pretty straightforward :

Private Sub DoOpenFile(ByVa l ThisFile As String)
Dim Line As String

Try
Dim sr As System.IO.Strea mReader = New
System.IO.Strea mReader(ThisFil e, True)
Line = sr.ReadLine()
sr.Close()
Catch Ex As Exception
MsgBox("Error reading file" & Chr(13) & Chr(13) & Ex.Message,
MsgBoxStyle.Cri tical Or MsgBoxStyle.OkO nly, "Error")
Exit Sub
End Try

Line = DoFormatLine(Li ne)
FillEditor(Line )
FileName = ThisFile
Editor.ReadOnly = False
Me.Text = "Editing " & FileName
End Sub

The text is created in an editor (MultiEdit) and looks like this:

FTX+AAK+1++Es bestehen Vereinbarungen, aus denen sich nachtr├Ągliche
Minderungen :des Entgelts ergeben k├Ânnen.+DE

When I open this in my app, it suddenly looks like this:

FTX+AAK+1++Es bestehen Vereinbarungen, aus denen sich nachtr´┐Żgliche
Minderungen :des Entgelts ergeben k´┐Żnnen.+DE
So, you are not writing the data using .NET's 'StreamWriter' at all. Most
likely the other application stores the file using the Windows ANSI encoding
with the system's default codepage. In order to read the file, pass
'System.Text.En coding.Default' to the 'StreamReader'' s constructor or
determine the encoding for a certain codepage using 'Encoding.GetEn coding'.
After your message I added the TRUE parameter in the streamreader (detect
encoding) and set the form's language to German... To no effect.
Well, detecting the encoding isn't always possible because byte sequences
contained in the file may be valid for different encodings.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jun 2 '07 #7
Hi Herfried,

Thanks a lot. Adding the parameter System.Text.Enc oding.Default did the
trick!
However, I also do a rewrite with the SreamWriter. I assume I need to add
the same parameter there?

Martin
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.atwrote in message
news:uY******** ******@TK2MSFTN GP05.phx.gbl...
"Martin" <x@y.comschrieb :
>The code Im using to read the file is I think pretty straightforward :

Private Sub DoOpenFile(ByVa l ThisFile As String)
Dim Line As String

Try
Dim sr As System.IO.Strea mReader = New
System.IO.Stre amReader(ThisFi le, True)
Line = sr.ReadLine()
sr.Close()
Catch Ex As Exception
MsgBox("Error reading file" & Chr(13) & Chr(13) & Ex.Message,
MsgBoxStyle.Cr itical Or MsgBoxStyle.OkO nly, "Error")
Exit Sub
End Try

Line = DoFormatLine(Li ne)
FillEditor(Line )
FileName = ThisFile
Editor.ReadOnly = False
Me.Text = "Editing " & FileName
End Sub

The text is created in an editor (MultiEdit) and looks like this:

FTX+AAK+1++E s bestehen Vereinbarungen, aus denen sich nachtr├Ągliche
Minderungen :des Entgelts ergeben k├Ânnen.+DE

When I open this in my app, it suddenly looks like this:

FTX+AAK+1++E s bestehen Vereinbarungen, aus denen sich nachtr´┐Żgliche
Minderungen :des Entgelts ergeben k´┐Żnnen.+DE

So, you are not writing the data using .NET's 'StreamWriter' at all. Most
likely the other application stores the file using the Windows ANSI
encoding with the system's default codepage. In order to read the file,
pass 'System.Text.En coding.Default' to the 'StreamReader'' s constructor or
determine the encoding for a certain codepage using
'Encoding.GetEn coding'.
>After your message I added the TRUE parameter in the streamreader (detect
encoding) and set the form's language to German... To no effect.

Well, detecting the encoding isn't always possible because byte sequences
contained in the file may be valid for different encodings.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Jun 2 '07 #8
"Martin" <x@y.comschrieb :
However, I also do a rewrite with the SreamWriter. I assume I need to add
the same parameter there?
Yes.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jun 2 '07 #9
Martin wrote:
Hi again,

The code Im using to read the file is I think pretty straightforward :

Private Sub DoOpenFile(ByVa l ThisFile As String)
Dim Line As String

Try
Dim sr As System.IO.Strea mReader = New
System.IO.Strea mReader(ThisFil e, True)
Line = sr.ReadLine()
sr.Close()
Catch Ex As Exception
MsgBox("Error reading file" & Chr(13) & Chr(13) & Ex.Message,
MsgBoxStyle.Cri tical Or MsgBoxStyle.OkO nly, "Error")
Exit Sub
End Try

Line = DoFormatLine(Li ne)
FillEditor(Line )
FileName = ThisFile
Editor.ReadOnly = False
Me.Text = "Editing " & FileName
End Sub

The text is created in an editor (MultiEdit) and looks like this:

FTX+AAK+1++Es bestehen Vereinbarungen, aus denen sich nachtr├Ągliche
Minderungen :des Entgelts ergeben k├Ânnen.+DE

When I open this in my app, it suddenly looks like this:

FTX+AAK+1++Es bestehen Vereinbarungen, aus denen sich nachtr´┐Żgliche
Minderungen :des Entgelts ergeben k´┐Żnnen.+DE

After your message I added the TRUE parameter in the streamreader
(detect encoding) and set the form's language to German... To no effect.

Tia,
Martin
Do you specify any encoding when you save the file? In the Windows
Notepad you do, I doubt that a more advanced editor would completely
lack this feature.

Save the file as UTF-8, and you should have no problems reading it.

--
G├Âran Andersson
_____
http://www.guffa.com
Jun 2 '07 #10

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

Similar topics

1
4761
by: Jeff | last post by:
Having a problem displaying both german and chinese characters from a UTF-8 database on the same *.jsp page. Can make Chinese characters appear correctly by including the following lines: <%@ page pageEncoding="UTF-8" %> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
1
1394
by: Irishmaninusa | last post by:
Hello Everyone, I have email form on a website and there is some fields that have german characters in it, like the umlat and so on, when I look at the email that is retuyrned I get the following message Form Name: E-Mail/Fax-Formular f├╝r den ValuePark ========== Other Data: ==========
1
4930
by: Manoj | last post by:
Hi All, I am using command line bcp utility of SQL Server to import data from a text file to database. I have some german words in the text file and after import the German characters are lost. see eg below. Input : KŘhner, Klaus -> Text file value
1
2490
by: Ajey | last post by:
Hi, I have a string which contains some german characters e.g 'MenŘ'. I am converting it to upper case using wcsupr (). But Ř is not converted to ▄. There are other characters too. I can use the _wsetlocale () function before using _wcsupr (). I cannot use the current machines locale setting. The strings have to be converted to upper case based on the locale of the target machine which is a SQL Server. What's the most efficient way of...
0
1580
by: Jean | last post by:
Hi everyone, Can someone help me please? I am using a form which imports a .csv file's data into a temporary table called tblQuestImport_csvraw. The problem is that I am working with a German character set here - whenever I import some text with those special characters, I get the wrong data in my temporary table. For example, ń becomes ¸, ÷ becomes an o with a little stripe above it, and Ř becomes the sign used for expressing a value...
4
34167
by: George | last post by:
Hi, I am puzzled by the following and seeking some assistance to help me understand what happened. I have very limited encoding knowledge. Our SAP system writes out a text file which includes German characters. 1. When I use StreamReader(System.String filepath) without specifying an encoding method, the German characters such as Ä are lost when I do a ReadLine()
0
1188
by: lakilevi | last post by:
Hi. I try to convert XML into HTML using XSL. Everything was ok until I used German characters. If I have german chars in the XML structure, and I display them with: <xsl:value-of select="german_word"/> than displays correct the characters. But I dont't want to take the german text from XML structure. This text is a constant table-header text, and I do not need to include it in te xml strucure. So I just want to display in XSL a simple...
1
4406
by: Sebarry | last post by:
Hi, I'm doing some work for a German website. They want to be able to type in characters for which there are HTML entities like &Uuml; &uuml; &auml;. The plain text should be stored in a database so it can be later retrieved and read into an XML file. The XML file is read by a Flash file to create a news ticker. Unfortunately the ticker is displaying some characters incorrectly. I thought that you would need to use html_entities when...
0
2353
by: rajana | last post by:
Dear All, We have Ansi file with german characters (─ / ě) , We are using Streamreader to read the contents of the file. But Readline() not able to read the German characters. We tried all possibilities of calling the streamreader, but nothing worked. Dim sr As StreamReader = New StreamReader(Filename, System.Text.Encoding.Default, True) Dim sr As StreamReader = New StreamReader(Filename, _System.Text.Encoding.ASCII, False, 512)
0
8678
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weĺll explore What is ONU, What Is Router, ONU & Routerĺs main usage, and What is the difference between ONU and Router. Letĺs take a closer look ! Part I. Meaning of...
0
8609
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9030
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph DuprÚ who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.