Tags and functions for globalizing

ColdFusion supplies many tags and functions that you can use to develop globalized applications. This section describes these tags and functions.

Using tags for globalizing applications

The following table shows the tags that you use most often to globalize an application:
Tag
Attributes
Use
cfprocessingdirective
pageencoding
Specify the encoding of a ColdFusion page so ColdFusion can parse it. For an example, see "Determining the character set of a ColdFusion page".
cfcontent
type
encoding
Specify the encoding of the results returned to the client browser. For an example, see "Determining the character set of server output".
cffile
encoding
Specify how to encode data written to or read from a file. For an example, see "Reading and writing file data".

Using functions for globalizing applications

ColdFusion contains functions that you use when globalizing an application. These functions include string functions as well as date, time, currency, and numeric functions.

String functions

ColdFusion provides the following functions to process string data:
Asc
Insert
LSParseNumber
REReplace
Chr
JavaCast
LTrim
REReplaceNoCase
CJustify
JSStringFormat
Mid
Reverse
Compare
LCase
MonthAsString
Right
CompareNoCase
Left
ParseDateTime
RJustify
DayOfWeekAsString
Len
REFind
RTrim
Encrypt
LJustify
REFindNoCase
SpanExcluding
FormatBaseN
ListValueCount
RemoveChars
SpanIncluding
Find
ListValueCountNoCase
RepeatString
ToBase64
FindNoCase
LSParseCurrency
Replace
Trim
FindOneOf
LSParseDateTime
ReplaceList
UCase
GetToken
LSParseEuroCurrency
ReplaceNoCase
Val
Hash

These functions recognize the Unicode encodings so they operate correctly for all single and double-byte character sets.

Note:   Applications developed for previous versions of ColdFusion that assumed that the character length of a string was the same as the byte length might produce errors in ColdFusion MX.

Date, time, currency, and numeric functions

CFML defines versions of the date, time, currency, and numeric functions that support different locales. The names of these functions are prefixed by LS. The following table lists the LS functions and several other functions used with date, time, currency, and numeric data:
Function
Function
DateConvert
LSIsNumeric
GetHttpTimeString
LSNumberFormat
GetLocale
LSParseCurrency
GetTimeZoneInfo
LSParseDateTime
LSCurrencyFormat
LSParseEuroCurrency
LSDateFormat
LSParseNumber
LSEuroCurrencyFormat
LSTimeFormat
LSIsCurrency
SetLocale
LSIsDate
 

You must precede calls to the LS functions with a call to the SetLocale() function in order to set the locale. If you do not, these functions default to using the locale defined by the JVM, which typically is the locale of the operating system.

The following example uses the LSDateFormat() function to display the current date in the formats for each locale supported by ColdFusion:

<!--- This example shows LSDateFormat --->
<html>
<head>
<title>LSDateFormat Example</title>
</head>
<body>
<h3>LSDateFormat Example</h3>
<p>Format the date part of a date/time value using the locale convention. 
<!--- loop through a list of locales; show date values for Now()--->
<cfloop list = "#Server.Coldfusion.SupportedLocales#"
  index = "locale" delimiters = ",">
  <cfset oldlocale = SetLocale(locale)>

  <cfoutput><p><B><I>#locale#</I></B><br>
    #LSDateFormat(Now(), "mmm-dd-yyyy")#<br>
    #LSDateFormat(Now(), "mmmm d, yyyy")#<br>
    #LSDateFormat(Now(), "mm/dd/yyyy")#<br>
    #LSDateFormat(Now(), "d-mmm-yyyy")#<br>
    #LSDateFormat(Now(), "ddd, mmmm dd, yyyy")#<br>
    #LSDateFormat(Now(), "d/m/yy")#<br>
    #LSDateFormat(Now())#<br>    
    <hr noshade>
  </cfoutput>
</cfloop>
</body>
</html> 

Comments