Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Swedish letters in richTextBox

Status
Not open for further replies.

AttilaTheHunn

Programmer
Joined
Nov 22, 2005
Messages
2
Location
SE
I'm working with a notepad in C#, and when you write in the textbox the lettters appear (å, ä, ö). But if you open a .txt-file my program can't read å, ä, ö.
 
Please post some code of how you are reading the textfile into your editor.

Regards, Ruffnekk
---
Is it my imagination or do buffalo wings taste just like chicken?
 
I'm using Stream reader:

DialogResult resultOpenFile = OpenFile.ShowDialog();
if (resultOpenFile == DialogResult.OK)
{
StreamReader of = new StreamReader(OpenFile.FileName); // Startar inläsning utav ful.
textBox.Text = of.ReadToEnd();
of.Close(); // Avslutar inläsningen.
sfd.FileName = OpenFile.FileName; // Föreslår samma filnamn som den öppnade filen.
string fil = Convert.ToString(Path.GetFileName(OpenFile.FileName)); // Gör om filnamnet till en string.
Text = fil + " - Textredigeraren " + Textredigeraren.info.version; // Gör så att filnamnet står med i titeln.
}
 
I think using UTF7 encoding will solve the problem. Try using:

Code:
StreamReader of = new StreamReader(OpenFile.FileName, System.Text.Encoding.UTF7);

Regards, Ruffnekk
---
Is it my imagination or do buffalo wings taste just like chicken?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top