I will first like to introduce myself since I am posting for the first time on the IEMobile blog. My name is Hiren and I work as a developer in the IEMobile team. Most of the content in the this entry is targeted towards general Windows Mobile device users with a small section at the end detailing IEMobile’s support for encoding detection targeted specifically towards web authors.
The Scenario:
Often times you want to be able to view web pages in a language different than the OS language for your Smartphone or PocketPC device. For example, a user may want to view pages in Japanese even though the default language for the device he/she is using is English. Web browsers support this scenario using an HTTP header called “Accept-Language” (defined in section 14.4 of HTTP 1.1 Header Field Definitions) which specifies a preferred Language for the web browser to the web server. If the server has the page available in the requested language the user will be able to view the page in that language which may or may not be same as the language for the device. For example, to set the preferred language to Finnish you could set the value of Accept-Language to “fi-FN” where the lowercase “fi” indicates Finnish and the uppercase “FI” indicates the country, Finland.
That’s great. How do I set the Language?
IEMobile supports setting the Accept-Language header to a desired language via a registry key. You can set the following registry key to one of the acceptable language tags for the Accept-Language header.
HKEY_CURRENT_USER\ Software\ Microsoft\ Internet Explorer\ International\ AcceptLanguage
RFC 1766 defines the acceptable values for the language tag. It refers to ISO 639 list for language codes and ISO 3166 list for country codes. You can actually specify multiple different preferred languages and a quality value indicating the preference level for each of them as well. For details, please refer to the HTTP header documentation (section 14.4 of HTTP 1.1 Header Field Definitions).
Note:
If the OS version you have supports this feature it does not matter if this key is not present by default in the registry. You should be able to create the registry key if it already does not exist and this will work.
Another thing to note is that you only need to enter the language code and not the entire header as the value of the above registry key. For example, “fi-FN” will be a valid value to set for the above registry key.
Which versions of the OS support this?
Only devices running Windows Mobile 2003 Second Edition ( including WM 5 ) or later support setting the accept-language header via the registry. This does not work for devices running older versions of the OS (even if you see the above key present in the registry).
Caveats
1. You will need to reboot the device after you change the registry for the changes to take effect.
2. You will also need to make sure you have the required font for the desired language installed on your device if you want to display pages in any East Asian languages like Chinese for example.
Switching between the two supported languages without changing the registry (Only for Smartphones)
Smartphone devices actually support two different languages out of the box. You can switch between these two languages by changing the setting in Settings | Regional Settings | Language. For example, most of the English phones also offer German as the other available option in the above setting. The Accept-Language header value sent out by IEMobile respects the language specified in this setting. In other words, if you just want to switch between these two languages while browsing you can just change the above setting and you don’t need to modify the registry as mentioned above. However, if you want to view pages in any other language then you will have to user the registry method specified above.
Note:
If the above specified registry key exists then the language specified in the registry key takes precedence over the language specified via the setting in Regional settings.
Specifying the character encoding for pages ( Target Audience: Web Authors )
A related topic for web authors is how to mark a page with a specific encoding so that the browser understands which encoding the page uses. HTML 4 specification section 5.2.2 mentions different ways of marking the character encoding for a page. IEMobile follows the standard as mentioned in section 5.2.2 for the most part. Specifying the “charset” param on the “Content-Type” header or a META declaration with “http-equiv” set to “Content-Type” works as mentioned in the standard. However, the 3rd method of specifying the encoding on a per element basis by setting the “charset” attribute on the element tag is not supported.
Detecting the encoding of the page based on the byte order mark (BOM) is only partially supported. IEMobile supports detection of utf-8 BOM header but utf-16 detection via BOM is not supported. However, utf-16 encoding can be used if the page is explicitly marked as such by the above mentioned supported methods.
- Hiren.