...
The database needs to be storing values in UTF-8. If it isn't, then all your effort is wasted. For example, on MySQL that means a db url like
No Format |
---|
jdbc:mysql://localhost/Example?capitalizeTypenames=true&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=UTF-8
|
And setting your default charset and collation in your my.cnf file
Or you can set these things at table create as below. One can also set these on the database as a whole.
mysql> show create table cards \G
*************************** 1. row ***************************
Table: cards
Create Table: CREATE TABLE `cards` (
`pk` int NOT NULL,
`creator_pk` int DEFAULT NULL,
`created_date` bigint DEFAULT NULL,
`invalid_date` bigint DEFAULT NULL,
PRIMARY KEY (`pk`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
Fonts & CSS
Different fonts may not have all the characters to display the different characters. If you're using a default stylesheet, then the browsers may be displaying differently simply because of fonts. Speaking of stylesheets, you probably want to encode that in UTF-8 also. Start your stylesheet with something like
No Format |
---|
@charset "UTF-8";
@import url("reset.css");
/* Begin site CSS */
|
...
I think this goes without saying but: Use Wonder. Set encoding in the properties file. Notice it is UTF-8 with a hyphen. It it always UTF-8 with a hyphen... well, except with the MySQL image above because they excel in doing things differently
No Format |
---|
# Project Encoding
er.extensions.ERXApplication.DefaultEncoding=UTF-8
|
Set encoding in your page wrapper
No Format |
---|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"
"http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg-flat.dtd">
|
...
Localizable.strings should be encoded in UTF-16. The localizer can detect UTF-16 without error, where it can confuse UTF-8 with other encodings. Pascal says use UTF-16LE if you want to be explicit about things... Especially if you are editing your strings files in an external editor like BBEdit or whatnot. I use the eclipse editor and UTF-16 myself and all seems to work fine for me. So to each his own.Specifically, you should be using UTF-16 BE with no BOM if you are using an external text editor instead of eclipse.
Build your files in UTF-8.
If you have some special characters in your code (like '€' for exemple), then you will need to specify which encoding you want when you build your application. To do that, you have to modify your "build.xml" file by adding the property "encoding="utf-8" into your <wocompile> statement.
Code Block | ||
---|---|---|
| ||
<wocompile srcdir="Sources" destdir="bin" encoding="utf-8">
|
...