-2

I want the german text to be displayed like simple English text in c#. I am reading a JSON file.

text = "Länder und Nationalitäten"

Expected = "Lander und Nationalitaten"

Actual = "L?nder und Nationalit?ten"

What i have tried :

System.Text.Encoding srcEnc = System.Text.Encoding.GetEncoding("ISO-8859-1"); System.Text.Encoding desEnc = System.Text.Encoding.GetEncoding("UTF-8");

Dormamu
  • 16
  • 4
  • 2
    And how did you do this? And - as a German speaker - _why_? You are butchering the language. The correct change would be "ä" => "ae" for Umlaute. What about "ß"? What would you expect that to become? Do you happen to have the displeasure to being forced to work with a legacy ASCII-only application? – Fildor May 31 '22 at 08:42
  • 3
    Look, even if you're a new programmer, there's no excuse for a question that's this light on details. You're reading JSON. What does that have to do with a PDF? Where is the [mcve]? – DiplomacyNotWar May 31 '22 at 08:42
  • How did you generate the PDF document? C# strings are Unicode. This very question proves this isn't a C# problem - SO is an ASP.NET Core application. PDF doesn't support Unicode by default though, it works with Latin 1 which includes German. Either the code that reads the input ended up mangling it, there was an explicit conversion to 7-bit US-ASCII that dropped all characters above 127, or the PDF generation code has a bug - perhaps because it forces 7-bit US-ASCII instead of Latin 1 – Panagiotis Kanavos May 31 '22 at 08:46
  • 2
    The two lines you posted don't explain anything. They don't explain how you read the source data or how you generated the PDF. They don't even try to convert to a different codepage - which is probably the bug that mangled the text in the first place. C# strings have no codepages, they're Unicode – Panagiotis Kanavos May 31 '22 at 08:50
  • I'm making a wild guess here that you're reading data from a JSON file and building a PDF file from it. This is my guess, as your question doesn't make this clear, and it seems logical to me. You could be having encoding issues reading the JSON file, you could be doing something strange with it in memory resulting in corruption, you could be missing a setting when generating the PDF, or some other issue. Not to mention that there's multiple JSON libraries and presumably multiple PDF libraries. Your question provides no useful information about what you're doing. How can we possibly identify.. – DiplomacyNotWar May 31 '22 at 08:55
  • ...what you're doing wrong without any of this information? – DiplomacyNotWar May 31 '22 at 08:56
  • Seems like you want to just remove the diacritics (Umlauts), if so, then check out [this](https://stackoverflow.com/q/249087/9363973) Q&A – MindSwipe May 31 '22 at 08:58

0 Answers0