Why an 8-hour day seems to take forever

by Michael S. Kaplan, published on 2005/10/29 03:01 -04:00, original URI: http://blogs.msdn.com/b/michkap/archive/2005/10/29/486617.aspx


Yoshihiro kawabata asked the suggestion box:

Hello, Michael.

About U+221E.
I test this code in SQL Server 2005.

select convert(varchar, nchar(0x221E))

Result:
'8' Collation(Latin1_General_CI_AS).
'∞' Collation(Japanese_CI_AS).

Why U+221E is convert to 8 in Latin1_General_CI_AS ?

The answer can be found in prior posts such as If the shoe [best-]fits.... and BestBetter than nothing fit mappings, unleashed, #1. In fact, if you look at that second post you will see that I marked this particular mapping as my favorite one.

What is clear is that SQL Server is simply calling WideCharToMultiByte without passing the WC_NO_BEST_FIT_CHARS flag. So any of the best fit mappings that exist in the code page are picked up.

At least now you know why a full eight-hour day at work can seem to take forever. Because depending on the code page you use, they can kind of be the same thing....

 

This post brought to you by "8" and "∞" (U+0038 and U+221e, a.k.a. DIGIT EIGHT and INFINITY)
Two characters who are great friends, merely a single best fit mapping away from each other!


# Heath Stewart on 29 Oct 2005 8:26 AM:

This is where earning a wage (as opposed to a salary) would be better - imagine all the overtime!

# Michael S. Kaplan on 29 Oct 2005 1:42 PM:

On the other hand, they might just pay you $8 and nothing more....

# Yoshihiro kawabata on 31 Oct 2005 12:01 AM:

Thanks,
Are there any encoding method in .NET Framework that can set WC_NO_BEST_FIT_CHARS on/off ?
If exists, I will try to create some conversion methods with WC_NO_BEST_FIT_CHARS by SQLCLR.

# Michael S. Kaplan on 31 Oct 2005 7:29 AM:

I am confused, Yoshihiro-san -- SQL Server does *not* use the flag, so why would you want to use it?

Using .NET 2.0, you can choose from many different encoding fallbacks, including a best fit one that matches the semantics of not passing this flag on Windows.

referenced by

2012/02/20 Where short file names can fail

2008/05/08 In hindsight, they may have BEST FIT these files where the sun never shines

2006/02/14 Every character has a story #18: U+06cc and U+064a (ARABIC LETTER FARSI YEH and ARABIC LETTER YEH)

go to newer or older post, or back to index or month or day