Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8742321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:28:46+00:00 2026-06-13T11:28:46+00:00

I’m sending signed XML via WebClient to a gateway. Now I have to ensure,

  • 0

I’m sending signed XML via WebClient to a gateway. Now I have to ensure, that the node values only contain german letters. I have 2 Testwords. The first gets very well converted by using:

string foreignString = "Łůj꣥ü";
Encoding utf8 = Encoding.UTF8;
Encoding iso = Encoding.GetEncoding("ISO-8859-1");
byte[] utfBytes = Encoding.Convert(iso, utf8, iso.GetBytes(foreignString));
string result = utf8.GetString(utfBytes);

But in the second string is a character which is also included in the UTF-8 Encoding. Its the

ç (Latin small letter c with cedilla)

After testing a little bit with other Encoding I always got the same result: the character was always there. What makes sense, because it is part of the UTF-8 table 🙂

So my question is: is there a way to mask out all the french, portuguese and spanish characters without dropping the german umlauts ?

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T11:28:48+00:00Added an answer on June 13, 2026 at 11:28 am

    You can create your own Encoding class based on the ISO-8859-1 encoding with your additional special rules:

    class GermanEncoding : Encoding {
    
      static readonly Encoding iso88791Encoding = Encoding.GetEncoding("ISO-8859-1");
    
      static readonly Dictionary<Char, Char> charMappingTable = new Dictionary<Char, Char> {
        { 'À', 'A' },
        { 'Á', 'A' },
        { 'Â', 'A' },
        { 'ç', 'c' },
        // Add more mappings
      };
    
      static readonly Dictionary<Byte, Byte> byteMappingTable = charMappingTable
        .ToDictionary(kvp => MapCharToByte(kvp.Key), kvp => MapCharToByte(kvp.Value));
    
      public override Int32 GetByteCount(Char[] chars, Int32 index, Int32 count) {
        return iso88791Encoding.GetByteCount(chars, index, count);
      }
    
      public override Int32 GetBytes(Char[] chars, Int32 charIndex, Int32 charCount, Byte[] bytes, Int32 byteIndex) {
        var count = iso88791Encoding.GetBytes(chars, charIndex, charCount, bytes, byteIndex);
        for (var i = byteIndex; i < byteIndex + count; ++i)
          if (byteMappingTable.ContainsKey(bytes[i]))
            bytes[i] = byteMappingTable[bytes[i]];
        return count;
      }
    
      public override Int32 GetCharCount(Byte[] bytes, Int32 index, Int32 count) {
        return iso88791Encoding.GetCharCount(bytes, index, count);
      }
    
      public override Int32 GetChars(Byte[] bytes, Int32 byteIndex, Int32 byteCount, Char[] chars, Int32 charIndex) {
        return iso88791Encoding.GetChars(bytes, byteIndex, byteCount, chars, charIndex);
      }
    
      public override Int32 GetMaxByteCount(Int32 charCount) {
        return iso88791Encoding.GetMaxByteCount(charCount);
      }
    
      public override Int32 GetMaxCharCount(Int32 byteCount) {
        return iso88791Encoding.GetMaxCharCount(byteCount);
      }
    
      static Byte MapCharToByte(Char c) {
        // NOTE: Assumes that each character encodes as a single byte.
        return iso88791Encoding.GetBytes(new[] { c })[0];
      }
    
    }
    

    This encoding is based on the fact that you want to use the ISO-8859-1 encoding with some additional restrictions where you want to map “non-german” characters to their ASCII equivalent. The built-in ISO-8859-1 encoding knows how to map Ł to L and because ISO-8859-1 is a single byte character set you can do additional mapping on the bytes because each byte corresponds to a character. This is done in the GetBytes method.

    You can “clean” a string using this code:

    var encoding = new GermanEncoding();
    string foreignString = "Łůj꣥üç";
    var bytes = encoding.GetBytes(foreignString);
    var result = encoding.GetString(bytes);
    

    The resulting string is LujeLAüc.

    Note that the implementation is quite simplistic and it uses a dictionary to perform the additional mapping step of the bytes. This might not be efficient but in that case you can consider alternatives like using a 256 byte mapping array. Also, you need to expand the charMappingTable to contain all the additional mappings you want to perform.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.