Changes for page UTF-8 Encoding Tips

Last modified by Ray Kiddy on 2022/01/11 21:36

From version 20.1
edited by Ray Kiddy
on 2022/01/11 21:36
Change comment: added example for table create
To version 17.1
edited by Antoine Berry
on 2012/09/20 10:32
Change comment: There is no comment for this version

Summary

Details

Page properties
Parent
... ... @@ -1,1 +1,0 @@
1 -Localization
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.kiddyr
1 +XWiki.aberry
Content
... ... @@ -1,12 +1,13 @@
1 1  = UTF-8 Encoding Tips =
2 2  
3 -Encoding questions are asked frequently on the mailing list. This is just a collection of tips for using UTF-8. It's a checklist of sorts. Make sure you've done all the things specified here before pitching your computer into the ocean
3 +Encoding questions are asked frequently on the mailing list. This is just a collection of tips for using UTF-8. It's a checklist of sorts. Make sure you've done all the things specified here before pitching your computer into the ocean :-)
4 4  
5 5  == Check your database ==
6 6  
7 -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
7 +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
8 8  
9 9  {{noformat}}
10 +
10 10  jdbc:mysql://localhost/Example?capitalizeTypenames=true&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=UTF-8
11 11  
12 12  {{/noformat}}
... ... @@ -13,20 +13,14 @@
13 13  
14 14  And setting your default charset and collation in your my.cnf file
15 15  
16 -[[image:attach:options.png]]
17 +[[image:options.png]]
17 17  
18 -Or you can set these things at table create as below. One can also set these on the database as a whole.
19 -
20 -
21 -\\\\\\\\\\\\\\\\
22 -
23 -{{{mysql> show create table cards \G*************************** 1. row ***************************       Table: cardsCreate 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}}}
24 -
25 25  == Fonts & CSS ==
26 26  
27 -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
21 +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
28 28  
29 29  {{noformat}}
24 +
30 30  @charset "UTF-8";
31 31  @import url("reset.css");
32 32  
... ... @@ -36,13 +36,14 @@
36 36  
37 37  == Set eclipse encoding ==
38 38  
39 -[[image:attach:preferences.png]]
34 +[[image:preferences.png]]
40 40  
41 41  == Use Project Wonder ==
42 42  
43 -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
38 +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 :-)
44 44  
45 45  {{noformat}}
41 +
46 46  # Project Encoding
47 47  er.extensions.ERXApplication.DefaultEncoding=UTF-8
48 48  
... ... @@ -51,6 +51,7 @@
51 51  == Set encoding in your page wrapper ==
52 52  
53 53  {{noformat}}
50 +
54 54  <?xml version="1.0" encoding="UTF-8" standalone="no"?>
55 55  <!DOCTYPE html PUBLIC
56 56   "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"
... ... @@ -58,9 +58,9 @@
58 58  
59 59  {{/noformat}}
60 60  
61 -== Localizable strings should be in UTF-16! ==
58 +== Localizable strings should be in UTF-16 ==
62 62  
63 -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. Specifically, you should be using UTF-16 BE with no BOM if you are using an external text editor instead of eclipse.
60 +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.
64 64  
65 65  == Build your files in UTF-8. ==
66 66  
... ... @@ -67,9 +67,7 @@
67 67  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.
68 68  
69 69  {{code language="xml"}}
67 +
70 70  <wocompile srcdir="Sources" destdir="bin" encoding="utf-8">
71 71  
72 72  {{/code}}
73 -
74 -(% class="auto-cursor-target" %)
75 -\\
options.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.XWikiGuest
Size
... ... @@ -1,1 +1,0 @@
1 -141.4 KB
Content
preferences.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.XWikiGuest
Size
... ... @@ -1,1 +1,0 @@
1 -106.8 KB
Content