Locale-Sensitive JavaScript Method
String.fromCodePoint(num, ...)
Internationalization (I18n) Method Overview
This static method converts one or more Unicode code points into a string of characters. Unlike
fromCharCode , which only supports 16-bit character codes from the Basic Multilingual Plane (BMP),
fromCodePoint supports character codes outside the BMP that require > 16-bit values
(called the High Surrogate character and the Low Surrogate character codes).
For example:
var result = String.fromCodePoint(0x010001); // decimal: 65537
Method returns:
result: "\uD800\uDC01" (Two 16-bit values: high surrogate + low surrogate = one Unicode character)
Click here (MDN) for additional details.
Note: This method is new, part of the ECMAScript 6 proposal, and so may not be supported by all browsers. Until approved, it is also subject to change.
I18n Issues
Whether or not calling fromCodePoint is an i18n issue is dependent on how it is being used in the application.
One possible issue is:
- The character codes are creating a string that is dependent on the language of the locale.
Suggested Replacement
If the resulting string is to be displayed to the user, make sure that fromCodePoint is passed the correct codes for the current locale.
Globalyzer will detect this method and report it as an I18n issue. If you have determined that the call is being handled correctly, you can
use Globalyzer's Ignore Comment
functionality to ensure that it isn't picked up in a subsequent scan.
Locale-Sensitive JavaScript Methods
|