Problem with ASCII based File Formats

SyntaxEditor for Windows Forms Forum

Posted 15 years ago by Wielage Dirk

I am trying to load ASCII (8 Bit/Central European code page) files into the SyntaxEditor! In a first look Everything works fine. I load the File via LoadFile Method using the ASCII Encoding! But if the Files Contains Characters like “ü” “ä” “ö” etc. a “?” is displayed instead of the character.
Is there no way to display characters from 0x80 to 0xFF correctly when its loaded from an not unicode encoded file?

In normal windows convertion methos the ? is a sign for an unicode character that is not convertable to the currently used ASCII Code page.
Why does this happen. The machine is running in the central european code page. So normally it should work.

So what must I do to edit these Files in the SyntaxEditor


[Modified at 05/05/2006 03:49 AM]

[Modified at 05/05/2006 03:59 AM]

Comments (2)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Dirk,

Our Document.LoadFile code is as simple as this:
FileStream stream = File.OpenRead(path);
StreamReader reader = new StreamReader(stream, encoding);
string text = reader.ReadToEnd();
Since .NET is Unicode based, you have to ensure that you pass the correct Encoding to LoadFile, which in turn is passed to the StreamReader we use (see above).

My recommendation would be to take that code, paste it in your app, and put a breakpoint after it to see what the "text" variable is set to. Try different Encodings until you find the appropriate one.

Actipro Software Support

Posted 15 years ago by Wielage Dirk
You are right!

I found the solution! Using the Encoding.Default might be the right way

.NET Framework Class Library
Encoding.Default Property
Gets an encoding for the system's current ANSI code page.

The latest build of this product (v21.1.0) was released 14 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.