Migrating ColdFusion 5 Applications
|
|
Migrating ColdFusion 5 Applications
|
Localization
This section describes the changes between ColdFusion 5 and ColdFusion MX that affect locale functions. It contains the following topics:
Note: Results from localization functions might differ, depending on your Java Runtime Environment (JRE). The contents of this section reflect tests on the SUN JRE version 1.4 and the IBM JRE version 1.3.0. Macromedia has also tested using the SUN JRE version 1.3.1_01; however, many of these tests failed on locales other than English(US).
Extended character code support
ColdFusion MX supports character code values 0-65535, whereas ColdFusion 5 supports 1-255. This affects string-processing functions. For more information, see Len()
in "CFML functions and variables".
Support for new currency formats
ColdFusion MX recognizes new currency formats for new locales. For example, when a Euro currency is passed into the LSIsCurrency
function, ColdFusion MX returns Yes if the locale is a Euro member, and No if not. Also, LSIsCurrency()
now returns "yes" for the locales and currency formats listed in the following table:
Locale |
Newly supported currency formats |
English(Australian) |
AUD123,456.78 |
English(Canadian) |
CAD123,456.78 |
English(New Zealand) |
NZD123,456.78 |
English(UK) |
£123,456.78 GBP123,456.78 |
French(Belgian) |
123.456,78 123.456,78 FB BEF123.456,78 |
French(Canadian) |
123 456,78 123 456,78 $ CAD123 456,78 |
French(Standard) |
123 456,78 123 456,78 F FRF123 456,78 |
French(Swiss) |
123'456.78 SFr. 123'456.78 CHF123'456.78 |
German(Austrian) |
öS 123.456,78 ATS123.456,78 |
Italian(Swiss) |
123'456.78 SFr. 123'456.78 CHF123'456.78 |
Norwegian(Bokmal), Norwegian(Nynorsk) |
123 456,78 kr 123 456,78 NOK123 456,78 |
Portuguese(Standard) |
123.456,78 Esc. PTE123.456,78 |
Portuguese(Brazilian)* |
12 de outubro de 1954 05h04min30s PST |
Spanish(Mexican) |
123,456.78 $123,456.78 MXN123,456.78 |
Swedish |
123 456,78 123 456,78 kr SEK123 456,78 |
* In ColdFusion MX for Portuguese (Brazilian), the Java medium time format (for example, 06:55:27
) does not work. However, the short, long, and full formats all work as expected; for example, 05h04min30s PST
, 5h4min30s PST
, and 05:04
.
For more information, see LSIsCurrency()
in CFML Reference.
Changes to formatting functions
ColdFusion MX uses Java standard locale formatting rules on all platforms. ColdFusion 5 uses Windows or UNIX locale formatting rules, depending on the ColdFusion platform. For information on Java standard locale formatting rules, see the Java documentation for the Locale class (java.util.Locale) at http://java.sun.com/j2se/1.3/docs/api/index.html.
Some functions in ColdFusion MX produce slightly different results than in ColdFusion 5. Many of these differences are improvements. For example, in ColdFusion MX, LSCurrencyFormat()
returns the correct international currency code for countries other than the US, and correctly rounds the currency values for countries whose currency does not include cents. The greatest improvement is that the same code produces the same results, regardless of the ColdFusion platform.
Some of the differences might require a slight adjustment in your ColdFusion application. For example, LSCurrencyFormat()
in ColdFusion MX formats some negative currency values differently than in ColdFusion 5, such as inserting a leading minus sign (-) instead of enclosing the value in parentheses.
The rest of this section describes changes that affect specific locales and every locale.
Changes to formatting functions for different locales
The following table shows the locales in which one or more functions produce slightly different results between ColdFusion 5 and ColdFusion MX:
Locale
|
Function
|
ColdFusion 5 results |
ColdFusion MX results |
English(Australian) |
LSCurrencyFormat(123456.78,"international") |
USD123,456.78 |
AUD123,456.78 |
LSCurrencyFormat("-1234.56","none") |
(1,234.56) |
-1,234.56 |
English(Canadian) |
LSCurrencyFormat(123456.78,"international") |
USD123,456.78 |
CAD123,456.78 |
LSCurrencyFormat("-1234.56","none") |
(1,234.56) |
-1,234.56 |
English (New Zealand) |
LSCurrencyFormat(123456.78,"international") |
USD123,456.78 |
NZD123,456.78 |
LSCurrencyFormat("-1234.56","none") |
(1,234.56) |
-1,234.56 |
English(UK) |
LSCurrencyFormat(123456.78,"local") |
$123 456.78 |
£123,456.78 |
LSCurrencyFormat(123456.78,"international") |
USD123,456.78 |
GBP123,456.78 |
LSCurrencyFormat("-1234.56","none") |
(1,234.56) |
-1,234.56 |
English(US) |
LSParseDateTime("23:15:16 4 Sept. 1998")* |
{ts '1998-09-04 23:15:16'} |
invalid date format error |
French(Belgian) |
LSCurrencyFormat(123456.78,"none") |
123 456,78 |
123.456,78 |
LSCurrencyFormat(123456.78,"local") |
123 456,78 F |
123.456,78 FB |
LSCurrencyFormat(123456.78,"international") |
FRF123 456,78 |
BEF123.456,78 |
French(Canadian) |
LSCurrencyFormat(123456.78,"local") |
123 456,78 F |
123 456,78 $ |
LSCurrencyFormat(123456.78,"international") |
FRF123 456,78 |
CAD123 456,78 |
LSCurrencyFormat("-1234.56","none") |
-1 234,56 |
(1 234,56) |
French(Swiss) |
LSCurrencyFormat(123456.78,"local") |
123 456,78 F |
SFr. 123'456.78 |
LSCurrencyFormat(123456.78,"international") |
FRF123 456,78 |
CHF123'456.78 |
German(Austrian) |
LSCurrencyFormat(123456.78,"local") |
123.456,78 DM |
öS 123.456,78 |
LSCurrencyFormat(123456.78,"international") |
DEM123.456,78 |
ATS123.456,78 |
Italian(Standard) |
LSCurrencyFormat(123456.78,"none") LSCurrencyFormat(123456.78,"none") |
12.345.678 |
123.457 |
Italian(Swiss) |
LSCurrencyFormat(123456.78,"none") |
12.345.678 |
123'456.78 |
LSCurrencyFormat(123456.78,"local") |
L. 12.345.678 |
SFr. 123'456.78 |
LSCurrencyFormat(123456.78,"international") |
ITL12.345.678 |
CHF123'456.78 |
Portuguese (Brazilian) |
LSCurrencyFormat("-1234.56","none") |
(1.234,56) |
-1.234,56 |
Portuguese (Standard) |
LSCurrencyFormat("-1234.56","none") |
(1.234,56) |
-1.234,56 |
LSCurrencyFormat(123456.78,"local") |
R$ 123.456,78 |
123.456,78 Esc. |
LSCurrencyFormat(123456.78,"international") |
BRL123.456,78 |
PTE123.456,78 |
Spanish(Mexican) |
LSCurrencyFormat(123456.78,"none") |
12.345.678 |
123,456.78 |
LSCurrencyFormat(123456.78,"local") |
12.345.678 pta |
123,456.78 |
LSCurrencyFormat(123456.78,"international") |
ESP12.345.678 |
MXN123,456.78 |
LSCurrencyFormat("-1234.56","none") |
-123.456 |
(1,234.56) |
Spanish (Standard), Spanish(Modern) |
LSCurrencyFormat(123456.78,"local") |
12.345.678 pta |
123.457 Pts |
LSCurrencyFormat(123456.78,"none") |
12.345.678 |
123.457 |
Swedish |
LSCurrencyFormat(123456.78,"none") |
123.456,78 |
123 456,78 |
* The medium
date format for English(US) has changed to the Java standard; for example, "Sept 4, 1998 11:15:16 PM" and "11:15:16 PM Sept. 4, 1998" are valid. For a list of valid date formats, see the Java documentation for the java.text.DateFormat
class at http://java.sun.com/j2se/1.3/docs/api/index.html. Spanish (Standard) and Spanish(Modern) map to the same Java locale ES_es. Therefore, whether you set the locale to Spanish(Modern) or Spanish(Standard), GetLocale()
returns Spanish(Standard).
For more information, see CFML Reference for the appropriate function.
Changes to formatting functions for every locale
The following table outlines changes to formatting functions that apply to every locale:
Function |
Description of change |
IsDateFormat()
|
When no mask is specified, ColdFusion MX returns the Java medium date format for the locale. ColdFusion 5 returns one of two default masks, depending on the locale:
- For a locale where the date ends with the year, the default mask is
dd-mmm-yy
- For a locale where the date begins with the year, the default mask is
yyyy-mmm-dd
|
IsTimeFormat()
|
ColdFusion MX supports the following masks for IsTimeFormat() :
- h:m:s
lsTimeFormat(6:39,"h:m:s") returns 06:39:0
- hh:mm:ss
lsTimeFormat(6:39,"hh:mm:ss") returns 06:39:00
- hh:mm:ss t
lsTimeFormat(6:28:26,"hh:mm:ss t") returns 06:28:26 A
- hh:mm:ss tt
lsTimeFormat(6:28:26,"hh:mm:ss tt") returns 06:28:26 AM
|
LSCurrencyFormat()
LSEuroCurrencyFormat()
|
ColdFusion 5 put "EUR" as the international currency for every locale, even if the locale did not support the Euro. For example, LSEuroCurrencyFormat(123.45, "international") returned "EUR123.45" , even for an English(US) locale. ColdFusion MX uses the Java standard locales. Therefore, ColdFusion MX processes LSCurrencyFormat() and LSEuroCurrencyFormat() as follows:
LSCurrencyFormat() returns the non-Euro currency format for all locales, even if the locale is a member of the Euro countries. For example, for the French(Standard) locale, LSCurrencyFormat() returns the French franc as the currency symbol, instead of the Euro.
LSEuroCurrencyFormat() only returns the Euro currency format if the set locale is a Euro member country. Otherwise, it returns the set locale's currency format or symbol. For example, LSEuroCurrencyFormat(-1234.56) returns -1 234,56 € for the French(Standard) locale, but returns ($1,234.56) for the English(US) locale.
|
LSDateFormat()
|
In ColdFusion 5, for the date parameter, you can only use a date/time object in the range of 100 AD-9999 AD. ColdFusion MX does not have this limitation. In ColdFusion MX, LSDateFormat() returns the appropriate date for the set locale. For example, LSDateFormat(12/01/02) returns Jan-12-2002 if the locale is set to English(UK), and Dec-01-2002 if the set locale is English(US). In ColdFusion 5, LSDateFormat() throws an error or returns an incorrect format. |
LSDateFormat()
LSTimeFormat()
|
If you pass an invalid mask into LSTimeFormat() or LSDateFormat() ; for example, "dd-mm-yymm" , the function outputs the invalid characters in both ColdFusion 5 and ColdFusion MX. However, ColdFusion 5 delimits each character of the output with an apostrophe (') character. |
LSIsCurrency()
|
When a Euro currency is passed into the LSIsCurrency function, ColdFusion MX returns "yes" if the locale is a Euro member, and "no" if not. |
LSIsDate()
|
In ColdFusion MX, you can pass in dates with the full date and full datetime parameters. These formats include the name of the day (for example, Wednesday). |
LSParseDateTime()
|
In earlier versions, you could not pass in a time zone value such as "EST". Now you can, but ColdFusion MX processes this information as follows:
- If the time zone specified in the date/time string parameter is different from the time zone setting of the computer hosting ColdFusion MX, ColdFusion MX changes the time value in the parameter to its equivalent value in the computer's time zone.
- If the time zone is not specified in the date/time string parameter, ColdFusion MX does not adjust the time value.
When developing an application, Macromedia recommends that you evaluate the entered time string for a time zone setting and, if necessary, change your application to adjust the value. You can use a cfcatch block to do this; for more information, see LSParseDateTime() and "CFCATCH variables" in CFML Reference. |
If you use the IBM JRE version 1.3.0 with ColdFusion MX, LSParseDateTime("Quarta-feira, 23 de Janeiro de 2002 12h34min56s PST") fails when passing the month "Janeiro". The following code works with the SUN JRE. |
Note: The date pivot point for calculating the century in a two-digit year has changed from ColdFusion 5, affecting the results from date functions. For more information, see "Date pivot point for two-digit years".
For more information, see CFML Reference for the relevant function.
Other locale-specific changes
Following are other locale-specific issues that could cause an incompatibility in your ColdFusion 5 applications:
- For the Japanese version, sort functions such as
ListSort()
and ArraySort()
return items in a slightly different order in ColdFusion MX than they do in the Japanese version of ColdFusion 5. This is because ColdFusion MX sorts characters by their Unicode char number, and the Japanese version of ColdFusion 5 sorts characters by their shift_jis char number.
- The format for how decimal numbers appear in a browser depends on the system locale of the computer that is hosting ColdFusion MX, not on the locale of ColdFusion MX. For example, if you run the English version of ColdFusion 5 on a computer whose system locale is set to German or French, the decimal point displays as a comma, not a period. ColdFusion 5 displays a period for the decimal point, regardless of the system locale.
GetLocale()
checks if the locale was explicitly set; for example, from Setlocale()
. If not, ColdFusion MX gets the default locale for the operating system from the Java Virtual Machine (JVM). If the operating system has no set locale, or if ColdFusion MX does not support the operating system's default locale, GetLocale returns en_US
"English (US)". (ColdFusion MX sets the locale in the JVM to en_US
"English (US)"; this value persists until the server is restarted or the value is reset with the SetLocale
function. This setting does not affect anything but ColdFusion MX.)
Comments