Date: | April 18, 2006 / year-entry #137 |
Tags: | code |
Orig Link: | https://blogs.msdn.microsoft.com/oldnewthing/20060418-11/?p=31493 |
Comments: | 9 |
Summary: | If you look at the NUMBERFMT structure, the way groups are expressed by the Grouping member do not match the value returned by LOCALE_SGROUPING: LOCALE_SGROUPING Grouping Sample Culture 3;0 3 1,234,567 United States 3;2;0 32 12,34,567 India 3 30 1234,567 (none I know of) LOCALE_SGROUPING expresses grouping as a series of semicolon-separated numbers, each expressing... |
If you look at the
The In other words, the two systems are basically the same, with the It's kind of strange that the two systems differ, considering that they both came from the same NLS team! It's probably a case of parallel evolution, wherein the locale-string folks and the number-formatting folks came up with their respective systems independently. Writing code to implement this conversion from Fortunately, in real life you rarely have need to perform this conversion, for you can just pass the desired locale as the first parameter to the |
Comments (9)
Comments are closed. |
Yesterday, when I talked about that post from Raymond about numeric grouping the locale sensitive way,…
Are there cultures that group decimal digits on the right-hand side of the decimal point as well?
For instance: 3.141,592,635,5
Tuesday, April 18, 2006 12:24 PM by Daev
> Are there cultures that group decimal digits
> on the right-hand side of the decimal point
> as well?
I wouldn’t call it a culture, but I saw that in some old ACM articles a few times. It took a moment to get used to it.
A bit more frequently I’ve seen spaces on the right-hand side of the decimal point.
I find it puzzling that Windows insists on formatting for Germany like "1.234.567,89" (cf. http://blogs.msdn.com/oldnewthing/archive/2006/04/17/577483.aspx). Although this is the "official" way to do it, from experience, almost no-one uses this scheme when hand-writing. Rather, the dots are replaced by spaces (thus, "1 234 567,89". Much more interesting, some people really have problems if they got values with dots ("1.234" will be treated as 1 + 234/1000 instead of 1234 by many people I know).
For example, I have yet to see any school teaching writing the dots for separating thousands; it is always a small space between the groups.
Is there anyone out there who feels the same like me?
"1.234" will be treated as 1 + 234/1000 instead of 1234 by many people I know"
Probably wasn’t the case before computers (with programs that don’t cater for different locales).
Example: when I was in school, we wrote dates like this: 21. VI 2006 (june 21st, 2006). It’s rarely done now. I don’t think it’s even possible to do it with computers. Pitty, no?
Goran: here you go! This is in PHP, as the C++ equivalent is about 20 lines. Requires a font with the appropriate codepoints.
<font face="Arial Unicode MS">
<?php
echo date(‘j’) . ‘. &#’ . (intval(date(‘n’)) + 0x215f) . ‘; ‘ . date(‘Y’);
// Use 0x216f for lowercase roman numerals. And date(‘n’) should be checked for errors.
?>
</font>
Ahem. I feel a bit dirty posting PHP here, even on a silly hack, so:
DateTime Now = DateTime.Now;
string Month = (Now.Month < 1 || Now.Month > 12) ? "MM" : "’" + (char)(0x215f + Now.Month) + "’";
string Date = Now.ToString("dd’.’ " + Month + " yyyy");
Not suggesting that anybody *does* this, of course…
Although it suddenly occurs to me that you could get the same effect by putting the roman numerals as the "short name" for a month (perhaps the ELKs could help).
[…] like "1.234.567,89" (cf. http://blogs.msdn.com/oldnewthing/archive/2006/04/17/577483.aspx). Although this is the "official" way to do it […]
German standard DIN 5008:2001 clearly says to write numbers like "1 234 567,89". Only amounts of money should be written "1.234.567,89 EUR".
PingBack from http://www.deez.info/sengelha/blog/2007/07/11/generating-and-parsing-localized-numbers-in-windows/