August 26, 2008

case shennigans

i really feel for our turkish cf brethren, they always seem to be getting the short end of the stick. a couple of weeks ago there was an issue in the support forums with someone using turkish locale (tr_TR) that was having problems getting case right using coldfusion's uCase() & lCase() functions. there's a couple of special characters, "i" & "ı" (that's small letter i & small letter dotless i) that are special cases when it comes to case mappings (bad pun willfully intended) which cf's functions weren't handling correctly. i was a bit perplexed by this, mainly as we usually deal with locales which have writing systems that don't have a concept of case but after poking around core java's String class it seems that cf wasn't using the overloaded versions of the toUpperCase()/toLowerCase() methods which pass in a locale to use to handle locale sensitive case. easy enough to fix in cf (i really love how easily coldfusion lets you workaround these little issues):

<cffunction name="toLowerCase" output="false" returntype="string" access="public">
<cfargument name="inString" required="true" type="string" hint="string to lower case">
<cfargument name="locale" required="false" default="en_US" type="string" hint="java style locale identifier to use to lower case input string">
<cfscript>
var thisLocale="";
var l=listFirst(arguments.locale,"_"); // language
var c=""; // country, we'll ignore variants
if (listLen(arguments.locale,"_") GT 1)
      c=uCase(listGetAt(arguments.locale,2,"_"));
// build locale
thisLocale=createObject("java","java.util.Locale").init(l,c);
return arguments.inString.toLowerCase(thisLocale);
</cfscript>
</cffunction>


<cffunction name="toUpperCase" output="false" returntype="string" access="public">
<cfargument name="inString" required="true" type="string" hint="string to upper case">
<cfargument name="locale" required="false" default="en_US" type="string" hint="java style locale identifier to use to upper case input string">
<cfscript>
var thisLocale="";
var l=listFirst(arguments.locale,"_"); // language
var c=""; // country, we'll ignore variants
if (listLen(arguments.locale,"_") GT 1)
      c=uCase(listGetAt(arguments.locale,2,"_"));
// build locale
thisLocale=createObject("java","java.util.Locale").init(l,c);
return arguments.inString.toUpperCase(thisLocale);
</cfscript>
</cffunction>

<cfscript>
s="#chr(105)##chr(305)##chr(223)#";
upperS=toUpperCase(s,"tr_TR");
lowerS=toLowerCase(upperS,"TR_TR");
writeoutput("input string: #s#<br> upper case: #upperS#<br>lower case: #lowerS#");
</cfscript>


notice how i didn't have to mess with the core java String class, i could just use it's methods on a cf string. even if you're not using tr_TR locale, you should note that "ß" (small letter sharp s) is also a special case, upper casing it actually turns it into 2 letters, "SS". i think there might also be some issues with some Greek characters as well.

Labels: ,

August 25, 2008

set your time--or else!

if you have servers/workstations in Thailand you probably should know that as of aug-23rd every business computer in the kingdom has to set it's time to the new TST (Thai Standard Time) or get fined a wheelbarrow full of money (from 100,000 to 500,000 baht, that's about $2500 to $15,000 US, yikes). i can understand the idea of using a timeserver to keep stuff in synch (really, who doesn't?) but man, that's a whopping big fine for being "time dumb" (especially if that's a per computer fine!). this article claims one of the reasons for doing this is so that everybody hears the national anthem at the same time.

the Royal Thai Navy's Hydrographic department is in charge of providing a national time server & it looks like they got windows covered at least (yes they devoted more than 1/2 of that page to windows 95/windows ME, no Mac, no Linux--not sure what stats they're running off).

in any case, if you're in Thailand, point your time server at:

time.navy.mi.th

and bob's your uncle. i like the idea of having a "local" time server so we swapped tout de suite. works plenty fine. the navy, as usual, did a bang up job.

Labels: ,

August 07, 2008

the end is nigh

my hair and fingernails starting following out. their's a gray pall over the whole landscape. the summer sun feels weak, like mid-winter. birds are dropping out of the sky. even the bugs stopped buzzing.

brett favre's a new york jet?

oh my.

Labels: