This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
tutorials:using_different_character_sets:start [2010/04/14 15:24] james |
tutorials:using_different_character_sets:start [2014/09/25 16:55] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Using Different Character Sets ====== | ====== Using Different Character Sets ====== | ||
- | To use and have **non-english** character sets within our software will require possibly a couple different changes. Our auction and classified software comes to you using **UTF-8** | + | <tip c n>**Note:** We recommend |
- | In config.php, | + | To use and have **non-english** character sets (Charset) within our software may need a few different changes, each listed on this page. Our auction and classified software comes to you using **UTF-8** character encoding by default((This includes the charset used in the admin panel, as well as the charset used in the default templates. |
- | define (' | + | <tip c n> |
- | If you do not see that line, then you may need to add it. This setting controls **filtering** of inputs | + | |
+ | ====== Charset in config.php file ====== | ||
+ | |||
+ | In **config.php**, | ||
+ | |||
+ | <code php> | ||
+ | |||
+ | If you do not see that line, then you may need to add it. This setting controls **filtering** of user-input | ||
+ | |||
+ | For most sites and languages, the setting above is the only one of the charset settings that needs to be changed in the **config.php** file. If the charset you need to use is **not** one of the [[http:// | ||
+ | |||
+ | <code php config.php charset section>/ | ||
+ | ----CHARSET Settings---- | ||
+ | |||
+ | The settings below are used for various operations that are charset sensitive, | ||
+ | for instance cleaning "user input" | ||
+ | to be un-commented (remove the #) to use. | ||
+ | |||
+ | For "input cleaning", | ||
+ | would normally be used, there is a 3 step process (below) to ensure that the | ||
+ | data is not corrupted due to differences in charsets. | ||
+ | 1 and 3 are skipped if the appropriate settings are not specified (Most sites | ||
+ | will only need to set CHARSET_CLEAN, | ||
+ | |||
+ | 1. (Optional step, only run if CHARSET_FROM is set): The input' | ||
+ | converted from the CHARSET_FROM setting to the CHARSET_CLEAN setting. | ||
+ | is converted either using mb_convert_string() or iconv(), according | ||
+ | to CLEAN_METHOD setting. | ||
+ | |||
+ | See http:// | ||
+ | CLEAN_METHOD to mb_convert_encoding. | ||
+ | to that function. | ||
+ | mb_convert_encoding is the default method used to convert the charset. | ||
+ | |||
+ | See http:// | ||
+ | to iconv. | ||
+ | |||
+ | This step, and optionally step 3, are necessary in order to be able to | ||
+ | clean any charset that is not compatible with the function | ||
+ | htmlspecialchars() (see step 2) | ||
+ | |||
+ | 2. (Always run): The input is " | ||
+ | This step will use the CHARSET_CLEAN setting for the charset, that charset must | ||
+ | be compatible with htmlspecialchars(). | ||
+ | |||
+ | This step is always run for security reasons, to prevent a certain type of | ||
+ | hacking called "Cross Site Scripting" | ||
+ | specified, or is not a compatible charset, the default of ISO-8859-1 is used. | ||
+ | |||
+ | See http:// | ||
+ | use. | ||
+ | |||
+ | 3. (Optional step, only run if CHARSET_TO is set): The cleaned input' | ||
+ | is converted from the CHARSET_CLEAN setting to the CHARSET_TO setting. It | ||
+ | is converted either using mb_convert_string() or iconv(), according | ||
+ | to CLEAN_METHOD setting. | ||
+ | |||
+ | See http:// | ||
+ | CLEAN_METHOD to mb_convert_encoding. | ||
+ | to that function, at this step. If CLEAN_METHOD is not set, and the function exists, | ||
+ | mb_convert_encoding is the default method used to convert the charset. | ||
+ | |||
+ | See http:// | ||
+ | to iconv. | ||
+ | this step. | ||
+ | */ | ||
+ | |||
+ | define(' | ||
+ | |||
+ | # | ||
+ | // | ||
+ | |||
+ | # | ||
+ | // | ||
+ | |||
+ | # | ||
+ | // | ||
+ | // | ||
+ | // | ||
+ | // | ||
+ | |||
+ | <tip c w> | ||
+ | |||
+ | <code php># | ||
+ | |||
+ | Most sites **should not use or change this setting**, it is used in a work-around for a very rare server configuration issue. | ||
+ | |||
+ | ====== Charset in Admin Panel ====== | ||
You will need to change the character encoding set within the admin tool to set the character encoding used in the admin tool here: | You will need to change the character encoding set within the admin tool to set the character encoding used in the admin tool here: | ||
- | SITE CONFIGURATION | + | [[admin_menu/ |
+ | |||
+ | If you do not have this setting we recommend updating to the latest version which will have it. Changing the setting here will allow you to insert characters directly into the browser when making changes in your admin panel, and those characters displayed properly without translation. | ||
+ | |||
+ | ====== Charset in Template(s) ====== | ||
+ | |||
+ | Within the templates used for your site, you may need to change the charset in the actual HTML code for your templates. | ||
- | If you do not have this setting we recommend updating to the latest version which will have it. Changing the setting here will allow you to insert characters directly into the browser and those characters displayed properly without translation. | + | The main change will be in the "XML Tag" in your template(s), |
- | Once the change is made in the admin tool directly you will need to make the necessary change in all of your page templates. The default character set is set to "iso-8859-1". All you need do is search for this text within your templates and replace with the character encoding you use within the admin tool. | + | <code html><? |
- | <tip c n>Tip: Most browsers can read the charset | + | You would change **utf-8** to the charset |
- | <meta http-equiv=" | + | <code html><meta http-equiv=" |
- | where **iso-8859-1** is replaced with whichever | + | You would change |