The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My work

  • My badges

  • Twitter Updates

  • My Flickr Stream

    20140508-Delphi-2007--Project-Options--Cannot-Edit-Application-Title-HelpFile-Icon-Theming

    20140430-Fiddler-Filter-Actions-Button-Run-Filterset-now

    20140424-Windows-7-free-disk-space

    More Photos
  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,715 other followers

Archive for June 11th, 2013

ASUS RT N66U did not update DDNS with changed IP addres

Posted by jpluimers on 2013/06/11

Today my router had an IP-address change, but didn’t update the DynDNS.org information in my My Host Services | My Dyn Account. Which meant I could not “phone home”, as I didn’t know the new IP-address**.

Lesson re-learned:

During initial router configuration, watch the router logs, as you might have accidentally updated the DynDNS.org by hand, not by your router

Had this in the ASUS Wireless Router RT-N66U – General Log:

Jun 11 08:01:53 notify_rc : restart_ddns
Jun 11 08:01:53 ddns: clear ddns cache file for server setting change
Jun 11 08:01:53 ddns update: connected to members.dyndns.org (204.13.248.111) on port 80.
Jun 11 08:01:53 ddns update: server output: HTTP/1.1 200 OK^M Date: Tue, 11 Jun 2013 06:01:53 GMT^M Server: Apache^M X-UpdateCode: X^M Content-Length: 7^M Connection: close^M ^M notfqdn
Jun 11 08:01:53 ddns update: malformed hostname: myhostname

The problem: hostname should not only be the name of the host, but the FQDN of the host. Read the rest of this entry »

Posted in ASUS RT-N66U, Network-and-equipment, Power User | Tagged: , , , , | 2 Comments »

.NET/C#: from Unicode to ASCII (yes, this is one-way): converting Diacritics to “regular” ASCII characters.

Posted by jpluimers on 2013/06/11

A while ago, I needed to export pure ASCII text from a .NET app.

An important step there is to convert the diacritics to “normal” ASCII characters. That turned out to be enough for this case.

This is the code I used which is based on Extension Methods and this trick from Blair Conrad:

The approach uses String.Normalize to split the input string into constituent glyphs (basically separating the “base” characters from the diacritics) and then scans the result and retains only the base characters. It’s just a little complicated, but really you’re looking at a complicated problem.

Example code:

using System;
using System.Text;
using System.Globalization;

namespace StringToAsciiConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            string unicode = "áìôüç";
            string ascii = unicode.ToAscii();
            Console.WriteLine("Unicode\t{0}", unicode);
            Console.WriteLine("ASCII\t{0}", ascii);
        }
    }

    public static class StringExtensions
    {
        public static string ToAscii(this string value)
        {
            return RemoveDiacritics(value);
        }

        // http://stackoverflow.com/questions/249087/how-do-i-remove-diacritics-accents-from-a-string-in-net
        private static string RemoveDiacritics(this string value)
        {
            string valueFormD = value.Normalize(NormalizationForm.FormD);
            StringBuilder stringBuilder = new StringBuilder();

            foreach (System.Char item in valueFormD)
            {
                UnicodeCategory unicodeCategory = CharUnicodeInfo.GetUnicodeCategory(item);
                if (unicodeCategory != UnicodeCategory.NonSpacingMark)
                {
                    stringBuilder.Append(item);
                }
            }

            return (stringBuilder.ToString().Normalize(NormalizationForm.FormC));
        }
    }
}

–jeroen

Posted in .NET, .NET 3.5, .NET 4.0, .NET 4.5, ASCII, C#, C# 3.0, C# 4.0, C# 5.0, Development, Encoding, Software Development, Unicode | Leave a Comment »

 
%d bloggers like this: