Technical

Interesting behavior of Umlaut characters


I found an interesting behavior with umlaut characters (ö,ü …). When we calculate the length of a string having umlaut characters (using string length function), different language compilers gives the different results.

I did some testing in some programming & scripting languages, and got some interesting results. Have a look

Java 5:
“ü”.length(); //output : 2 (count 2 for umlaut character)
“üö”.length(); //output : 4
“aüö”.length(); //output : 5 (count 1 for simple characters and 2 for umlaut characters)

Javascript (tested on Firefox 2.0, IE6.0):
“ü”.length; //output : 1
“üö”.length; //output : 2
“aüö”.length; //output : 3

VBScript (tested on IE6.0):
Len(“ü”) //output : 1
Len(“üö”) //output : 2
Len(“aüö”) //output : 3

C#.NET (2005):
“ö”.Length; //output : 1
“üö”.Length; //output : 2
“aüö”.Length;//output : 3

VB.NET (2005):
“ö”.Length //output : 1
“üö”.Length //output : 2
“aüö”.Length//output : 3

PHP:
strlen(“ü”); //output : 2 (count 2 for umlaut character)
strlen(“üö”); //output : 4
strlen(“aüö”); //output : 5 (count 1 for simple characters and 2 for umlaut characters)

Turbo C++:
strlen(“ü”); //output : 1
strlen(“üö”); //output : 2
strlen(“aüö”); //output : 3

Your comments and views are invited.

Advertisements

2 thoughts on “Interesting behavior of Umlaut characters

  1. What a dhasu blog… I love it…It gives me that information that i want urgently..Thanks mohit…ur just a true frnd….GOD BLESS U…ALWAYS…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s