Welcome to MSDN Blogs Sign in | Join | Help

March 2005 - Posts

CultureInfo Caching and ClearCachedData()

Windows and the .Net Framework work a bit differently when it comes to accessing culture/locale data. Since I'm discussing Windows locales and .Net cultures I’d like to point out that culture and locales provide similar functionality. We generally refer

Example using Custom Cultures to "combine" cultures in .Net Framework v2.0 (Whidbey)

A few of you have asked how to create something like es-US. (Spanish in the US). Here's a start of how you might do something like that. This code has many faults and concerns, so you should look at how these work for your application. I didn't include

UTF8 Security and Whidbey Changes

Unicode is always in the process of evolving, and some changes have been made to UTF8 in the last few versions. The UTF-8 algorithm is fairly simple, but there are a few clarifications that are important for security reasons. Primarily there is the requirement

"Precomposed" and "Composite" Characters in Windows APIs

The term Composite and Precomposed in the Windows docs give me trouble, so I suspect they give other people trouble. Basically Unicode provides 2 ways of encoding some characters. Sometimes a character can be encoded as a single character (like Ä or U+00C4),

MultiByteToWideChar ignores MB_PRECOMPOSED behavior for UTF-8 and UTF-7

UTF7 and UTF8 conversion by MultiByteToWideChar and WideCharToMultiByte is strictly Unicode to Unicode and none of the flags are honored except for WC_ERR_INVALID_CHARS. I've noticed a few cases where people expect MB_PRECOMPOSED behavior because the

How the various CultureInfo names and tags behave.

With the introduction of sort names and custom cultures in the .Net Framework 2.0 (Whidbey) a few things about culture names had to be clarified. Three are 4 ways you can get names that look a lot like culture names: 1) CultureInfo.Name 2) CultureInfo.ToString()

Try to identify cultures by string name instead of LCID

It is a good idea to avoid using the locale LCID when referring to cultures in .Net. Instead, use the language tag (e.g. use “en-US” instead of 0x0409). The biggest obvious reason is Custom Cultures. All custom cultures share the same LCID, so new CultureInfo(custom

Whidbey Beta 2 bug with CreateSpecificCulture() for Neutral Custom Cultures.

There's a bug in Whidbey Beta 2 where CreateSpecificCulture() will return invariant for any neutral custom culture, including both replacement and supplimentary cultures. So even replacements of something like "en" will have Invariant instead of "en-US"

Neutral Cultures and CreateSpecificCulture()

Many of you have observed that some things don't work with neutral cultures. Some fields require culture specific data to behave correctly. For example, in en-US, you might expect M/d/yyyy for a date pattern, however en-GB has dd/MM/yyyy and en-ZA has

Don't Use Encoding.Default

So you want to save some data and don't know which Encoding to use. My biggest suggestion is please do NOT use Encoding.Default. Huh? That can't be right. You heard me right, please don't use Encoding.Default. Encoding.Default sounds like the right thing

What's the difference between an Encoding, Code Page, Character Set and Unicode?

Encoding, Code Page and Character Set are often used interchangeably, even when that isn't strictly correct. There are some distinctions though: Characters are usually thought of as the smallest element of writing that has a meaning. It could be a punctuation

"So Why Isn't Latin Shipped With the Framework?"

Lots of people ask this question, replacing Latin with their favorite language. http://www.ethnologue.com/language_index.asp might give a hint as to the size of the general problem. There are about 6800 known languages, in many more language/country combinations.

Whidbey .Net 2.0 Custom Culture Example (Beta 2)

Here’s an example of how to create a custom culture in Whidbey. Its changed a bit from earlier versions, so this code is based on Beta 2 behavior. This should be what you see in RTM. J This sample creates a custom culture with the name “en-US-shawn”,

Rambling on About Custom Cultures in .Net 2.0 (Whidbey)

People keep asking questions like “How do I get Latin cultures in .Net?” Well, in Whidbey we’re adding Custom Cultures. A custom culture is a culture that is created and installed on the system by a user with admin privileges. Once installed custom cultures

IDN & Homographs

I’ve divided this into a few parts: About IDN IDN & Security Homograph Thoughts Conclusion About IDN: My interest in IDN is that I’m the SDE for the System.Globalization.IdnMapping class in Whidbey . I also think its pretty nifty for the users in

What's with Encoding.GetMaxByteCount() and Encoding.GetMaxCharCount()?

The behavior of Encoding.GetMaxByteCount() changed somewhat between .Net version 1.0/1.1 and version 2.0 (Whidbey). The reason for this change is partially because GetMaxByteCount() didn't always return the worst-case byte count, and also because the
 
Page view tracker