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()
I understand that by default UTF8Encoding is used.
2. When I use StreamReader(System.String filepath,
System.Text.Encoding.Unicode), I got garbage data in. I am not surprised by
this as our SAP system is not configured to read/write Unicode text output.
3. When I use StreamReader(System.String filepath,
System.Text.Encoding.Default), reading German characters are not a problem.
I guess this is also why I am able to read these German characters in
Wordpad.exe, as it must. Through debugger, I was able to find out that
System.Text.Encoding.Default is equal to System.Text.SBCSCodePageEncoding.
Does anyone has any idea what is System.Text.SBCSCodePageEncoding? Is it
one type of "extended ASCII" encoding methods?
4. My guess is that SAP text writing encoding happens to be "compatible"
with my system's default encoding, and this is why StreamReader(filepath,
System.Text.Encoding.Default) worked. If they are not compatible, it would
not have worked. Is that correct?
5. Is there a "cover all cases and automatic" type of encoding method? An
encoding method which is smart enough to detect and encode/decode to the
correct encoding on the fly. (This is encoding beginner's question....)
Thanks,
--
George