php - Croatian letters enconding + Twitter Bootstrap + Helvetica Neue Pro -


twitter bootstrap won't show letter đ ć č ž š,croatian letters. set charset utf-8 , won't do... i'm getting data form mysql , in database ok, first tought font helvetica,so helvetica neue pro lt but...not sure load correctly...any idea how load...twitter bootstap + font awesome,

so tired arial, , won't work!

so help? tnx alot

there can several reasons.

before troubleshooting database, should first try static content ensure editor , server correctly set up.

try adding html content php file contains croatian characters. if these characters come out wrong in browser, make sure:

  1. your code editor saves php files using utf-8 encoding
  2. your webserver outputs php files utf-8. check this, @ http header in browser. there should line named "content-type" value of "text/html; charset=utf-8". @ screenshot chrome locate http header: http://www.jesperkristensen.dk/webstandarder/doctype-chooser/chrome.png

if static characters come out right, next step troubleshoot database.

the character set

computers know numbers nature, internally computer thinks of letters , characters numbers. example, letter a is, default, stored number 97 on american computers, while b 98. complete list, see http://www.asciitable.com/

very simplified put, whenever displaying characters on screen, computer use numeric value , value in font library find appropriate glyph display on screen.

the set of glyphs (characters) computer searching whenever displaying text called character set. specific encoding rules, define numbers map glyphs in character set, called character encodings.

when people talk ascii set talking collection of glyphs include english alphabet in both uppercase , lowercase, arabic numbers (0-9) , handful of special characters. may referring ascii character encoding specifies numbers map glyphs. again - see www.asciitable.com

unfortunately, there more english latin characters , computers proliferated throughout world in 60's , 70's, local character sets, fonts , encodings invented suit local needs. these have esoteric names iso-8859-5, euc-jp or ibm860.

attempting read text using different character encoding standard text encoded cause headaches. english characters work, because represented same across different encodings , sets, else break. instance, character æ special danish vowel character has numeric value of 230 when using iso-8859-1 standard predominant encoding standard in denmark. however, if saved text file containing in denmark, apple called æble. floppy disk , sent friend in bulgaria, computer assume text file encoded using iso-8859-5 standard cyrillic texts , show in denmark, apple called цble wrong, because according iso-8859-5 standard numeric value of 230 maps ц.

to compare 2 character encodings, please see: http://en.wikipedia.org/wiki/iso/iec_8859-1 http://en.wikipedia.org/wiki/iso/iec_8859-5

in olden days, developers had pick character set , encoding use application, because no universal solution existed, fortunately new character set called unicode evolved in 1990's.

this character set includes thousands , thousands of glyphs around world, enough cover pretty every current alphabet , language in world. unicode, few specifications on how encode text devised. popular today called utf-8, conveniently backwards compatible old american ascii 7-bit character encoding. because of that, valid ascii text valid utf-8 text. backward compatibility curse, because leads novice developers conclude software working, when in fact working characters present in ascii character set.

first step - making sure database storing text utf-8

before can display text correctly, must stored correctly. use sql management tool check character encoding table working with. if no information present, defaults inherited database schema or server configuration, check too.

if table not using utf-8 or unable verify using utf-8, may run command in sql tool against table explicitly instruct database store data using utf-8:

alter table name_of_your_table character set utf8 collate utf_unicode_ci; 

this tells database store data using utf-8 encoding, making capable of storing special characters. databases uses concept called collation set of rules on how glyphs sorted , compared. instance ß may interpreted 2 s characters in german, while other languages might consider special character comes before or after normal latin characters when sorting. unless have reason, use utf_unicode_ci collation language agnostic , sort things correctly. _ci in name means case insensitive, meaning when doing comparisons such where country = usa, records in lowercase match.

second step - webserver , database needs speak utf-8 together

now database storing things right way, have make sure webserver , database communicating correctly too. again, multitude of environment settings affect defaults, it's idea explicit when connecting database. if using pdo in php connect, can use following example connect (taken php.net) :

<?php $dsn = 'mysql:host=localhost;dbname=testdb'; $username = 'username'; $password = 'password'; $options = array(     pdo::mysql_attr_init_command => 'set names utf8', );   $dbh = new pdo($dsn, $username, $password, $options); ?> 

what important here options associative array. contains "set names utf8" sql command run against database whenever connection opened. has 2 implications.

  1. it instructs database queries sent subsequently encoded using utf-8. way database understand non-ascii characters coming webserver.
  2. it instructs database responses returned database web server, assumed, web server, encoded using utf-8 , treated such.

with database stores data using utf-8 encoding , web server connects , transfers query results using utf-8 encoding, should ready display croatian characters on website.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -