• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 410
  • Last Modified:

iso charset

how do i use this http://www.loc.gov/standards/iso639-2/php/code_list.php  to change the charset in php?

thanks in advance for help!
  • 7
  • 3
  • 2
  • +2
1 Solution
as my knowledge i think set charset is not related to php it's related to html.
but if you want to set it with php you should using following code
header('Content-type: text/html; charset=utf-8');

Open in new window

only1wizardAuthor Commented:
not charset but the codec if you will look at the link provided is a list of of codecs.

what im trying to do is set the locale

/* Set locale to Dutch */
setlocale(LC_ALL, 'nl_NL');

/* Output: vrijdag 22 december 1978 */
echo strftime("%A %e %B %Y", mktime(0, 0, 0, 12, 22, 1978));

/* try different possible locale names for german as of PHP 4.3.0 */
$loc_de = setlocale(LC_ALL, 'jpn');
echo "Preferred locale for german on this system is '$loc_de'";

Open in new window

how ever when i use japan which is jpn i get nothing.
in my code snippet i have following code:

         * List of ISO-639-1.
         * Two letter code to Language mapping
         * If you need three letter code to Language mappng,
         * then fetch ISO-639-2


            'aa' => 'Afar',

            'ab' => 'Abkhazian',

            'af' => 'Afrikaans',

            'am' => 'Amharic',

            'ar' => 'Arabic',

            'as' => 'Assamese',

            'ay' => 'Aymara',

            'az' => 'Azerbaijani',

            'ba' => 'Bashkir',

            'be' => 'Byelorussian',

            'bg' => 'Bulgarian',

            'bh' => 'Bihari',

            'bi' => 'Bislama',

            'bn' => 'Bengali; Bangla',

            'bo' => 'Tibetan',

            'br' => 'Breton',

            'ca' => 'Catalan',

            'co' => 'Corsican',

            'cs' => 'Czech',

            'cy' => 'Welsh',

            'da' => 'Danish',

            'de' => 'German',

            'dz' => 'Bhutani',

            'el' => 'Greek',

            'en' => 'English',

            'eo' => 'Esperanto',

            'es' => 'Spanish',

            'et' => 'Estonian',

            'eu' => 'Basque',

            'fa' => 'Persian',

            'fi' => 'Finnish',

            'fj' => 'Fiji',

            'fo' => 'Faeroese',

            'fr' => 'French',

            'fy' => 'Frisian',

            'ga' => 'Irish',

            'gd' => 'Scots Gaelic',

            'gl' => 'Galician',

            'gn' => 'Guarani',

            'gu' => 'Gujarati',

            'ha' => 'Hausa',

            'hi' => 'Hindi',

            'hr' => 'Croatian',

            'hu' => 'Hungarian',

            'hy' => 'Armenian',

            'ia' => 'Interlingua',

            'ie' => 'Interlingue',

            'ik' => 'Inupiak',

            'in' => 'Indonesian',

            'is' => 'Icelandic',

            'it' => 'Italian',

            'iw' => 'Hebrew',

            'ja' => 'Japanese',

            'ji' => 'Yiddish',

            'jw' => 'Javanese',

            'ka' => 'Georgian',

            'kk' => 'Kazakh',

            'kl' => 'Greenlandic',

            'km' => 'Cambodian',

            'kn' => 'Kannada',

            'ko' => 'Korean',

            'ks' => 'Kashmiri',

            'ku' => 'Kurdish',

            'ky' => 'Kirghiz',

            'la' => 'Latin',

            'ln' => 'Lingala',

            'lo' => 'Laothian',

            'lt' => 'Lithuanian',

            'lv' => 'Latvian, Lettish',

            'mg' => 'Malagasy',

            'mi' => 'Maori',

            'mk' => 'Macedonian',

            'ml' => 'Malayalam',

            'mn' => 'Mongolian',

            'mo' => 'Moldavian',

            'mr' => 'Marathi',

            'ms' => 'Malay',

            'mt' => 'Maltese',

            'my' => 'Burmese',

            'na' => 'Nauru',

            'ne' => 'Nepali',

            'nl' => 'Dutch',

            'no' => 'Norwegian',

            'oc' => 'Occitan',

            'om' => '(Afan) Oromo',

            'or' => 'Oriya',

            'pa' => 'Punjabi',

            'pl' => 'Polish',

            'ps' => 'Pashto, Pushto',

            'pt' => 'Portuguese',

            'qu' => 'Quechua',

            'rm' => 'Rhaeto-Romance',

            'rn' => 'Kirundi',

            'ro' => 'Romanian',

            'ru' => 'Russian',

            'rw' => 'Kinyarwanda',

            'sa' => 'Sanskrit',

            'sd' => 'Sindhi',

            'sg' => 'Sangro',

            'sh' => 'Serbo-Croatian',

            'si' => 'Singhalese',

            'sk' => 'Slovak',

            'sl' => 'Slovenian',

            'sm' => 'Samoan',

            'sn' => 'Shona',

            'so' => 'Somali',

            'sq' => 'Albanian',

            'sr' => 'Serbian',

            'ss' => 'Siswati',

            'st' => 'Sesotho',

            'su' => 'Sundanese',

            'sv' => 'Swedish',

            'sw' => 'Swahili',

            'ta' => 'Tamil',

            'te' => 'Tegulu',

            'tg' => 'Tajik',

            'th' => 'Thai',

            'ti' => 'Tigrinya',

            'tk' => 'Turkmen',

            'tl' => 'Tagalog',

            'tn' => 'Setswana',

            'to' => 'Tonga',

            'tr' => 'Turkish',

            'ts' => 'Tsonga',

            'tt' => 'Tatar',

            'tw' => 'Twi',

            'uk' => 'Ukrainian',

            'ur' => 'Urdu',

            'uz' => 'Uzbek',

            'vi' => 'Vietnamese',

            'vo' => 'Volapuk',

            'wo' => 'Wolof',

            'xh' => 'Xhosa',

            'yo' => 'Yoruba',

            'zh' => 'Chinese',

            'zu' => 'Zulu');

Open in new window


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Ray PaseurCommented:
Ypu are doing the right thing by using the setlocale function; you need to remember that this function sets locale information including time numbers money formats collate, characters conversion  and more.
See this link for the list of categories.
only1wizardAuthor Commented:
sorry for the late response just been busy.

this is the way i want to go is with setlocale.

do you have a link for the language section for setlocale function?

thanks in advance for your help!
only1wizardAuthor Commented:
@ray can you show me an example on how to use iso 639-1 to set the language based on user language setting through geolocation region/state/ip?

what im trying to acomplish is:

1. grab current users language
2. change the default websites language to use their language standards closest to their region based upon the region/state/providence/ip address provided per user.
3. have sub domains for each region(language (primary))
4. default language going into the database would be english but the user will input their language say japanesse and its inserts as english but displays as japaneese. im using utf-unicode-ci to ensure that the database can handle majority of languages.
5. sorry for such a delay on this open question! thanks in advance for your help!
greetings only1wizard, you say -> "how ever when i use japan which is jpn i get nothing", if you are getting some text out put with other languages, and not Japanese, it may be that it is not the setlocale( ) function or other PHP, it may be that on your computer there are NOT mutibyte charaters for the Japanese output in your browser, or there may not be settings for Japanese placed in your operating system. I had problems in understanding the very different display considerations for mutibyte character sets that are not from the Latin-european language base. This seems to be a difficult thing to do a multi language web site, at least for me. You may consider some of the "Web Page translators" like Google translate at -
only1wizardAuthor Commented:
i will read into that thank u!
Ray PaseurCommented:
example on how to use iso 639-1 to set the language based on user language setting through geolocation region/state/ip?

There are many moving parts to that request, and integrating them will be a painstaking and laborious process.  And after you have gone to the trouble to do all of that, you will find that you have annoyed your clients by forcing (for example) the French to use the German version of the web site when their travels take them to Germany, where the automation will choose German.  But that said, ...

How to map IP address to country

How to do it the "nice" way and let your client choose the preferred language

Note that in the second article, the web site uses subdirectories, not subdomains.  I suppose you could use subdomains if you wanted to.  You would need to be careful of sessions and cookies with subdomains.  This is the way PHP.net works (using subdirectories).  

Note also this quote from PHP.net: PHP only supports a 256-character set, and hence does not offer native Unicode support.

You can learn more about character encoding and how to use multi-byte characters in this article.

PHP supports internationalization and multi-byte characters, sort of, via extensions

From PHP.net:
Ultimately, this means writing correct programs using Unicode depends on carefully avoiding functions that will not work and that most likely will corrupt the data and using instead the functions that do behave correctly, generally from the intl and mbstring extensions. However, using functions that can handle Unicode encodings is just the beginning. No matter the functions the language provides, it is essential to know the Unicode specification. For instance, a program that assumes there is only uppercase and lowercase is making a wrong assumption.

It's a big challenge to internationalize a web site.  Best of luck with it, ~Ray
only1wizardAuthor Commented:
@ray thank you i will read into this and post my response at a later time!
Ray PaseurCommented:
Take your time and enjoy the new year - I will be here!
only1wizardAuthor Commented:
thank you u2
only1wizardAuthor Commented:
thanks for your help with internationalize a website!

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 7
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now