I am trying to save a string in database and get something like this
Период д

The string that I want to save : Период действия S...
The table encoding is: cp1251_general_ci
I don't know in which encoding the string is - I am getting it from an excel document.
I tried this, but it didn' help.
$nomer = iconv('UTF-8','Windows-1251', $str );
Is there a solution for this?
You haven't mentioned the database engine you're using, but try changing the table encoding to something like utf8_general_ci or utf8_unicode_ci.
Related
I have a mysql database with latin1 default character set name.
Through php I save strings in mysql table. From the table I parse some data into tables using DataTables.
Everything work ok, but now I have some problems with circumflex letters and FPDF.
So if I save a string "račun" in the table, the result in the table will be "raÄun".
Or the string "število" will be "Å¡tevilo".
OK -> DataTables decodes those words back normally..
But now when I am using FPDF it gets those string as they are stored in MySQL table and print them "encoded".
I tried
iconv("ISO-8859-1", "ISO-8859-2", "Števika računa")
and
utf8_decode("Števika računa)
But nothing worked.. does anybody has an idea what should I do?
At the end this was the solution:
http://isabelcastillo.com/international-characters-encoding-fpdf
I have to store the phonetics of words in a database in this format:
blow = \ˈblō\
But when I see in the database, it's stored like this:
blow = \?bl?\
There are ? instead of symbols you can see.
Please correct me as to what I am doing wrong.
Thanks
your database does not support all characters i would recommend to change it to something like this:
character set: utf8
collation: utf8_general_ci
right now you have a standard character set and thats why it changes to ?????
I have a site developed in codeigniter where I'd like to insert a record inside my database in a table with utf8 fields.
The problem is that when I insert something inside the table I see that:
�"�h�t�t�p�:�/�/�I�m�a�g�e�1�.�u�r�l�f�o�r�i�m�a�g�e�s�.�c�o�m�/�D�e�f�a�u�l�t�/�8�8�0�4�/�2�3�6�9�2�2�6�2�-�1�8�4�3�3�8�5�2�6�6�.�j�p�g�"�
There are many more characters. The real string is a simple path. I don't know the format of the string because it is from an external server.
This is my query to insert record. I take the string from xml and if I print it inside the page I see the correct string. The problem occurs whenever I check inside the database:
foreach($img->childNodes as $node){
$data = array(
'image'=>$node->getAttribute('path'),
);
$this->db->insert('hotel_images',$data);
}
That data is not UTF-8. It is UCS-2 or UTF-16. UCS-2 is a subset of UTF-16, so treating it as UTF-16 should do the trick.
You can convert it using iconv.
$data = iconv("UTF-16", "UTF-8", $data);
this might look like a similar issues for utf8 and Arabic language with MySQL database but i searched for result and found none..
my database endocing is set to utf8_general_ci ,
i had my php paging to be encoded as ansi by default
the arabic language in database shows as : ãÌÑÈ
but i changed it to utf8 ,
if i add new input to database , the arabic language in database shows as : زين
i dont care how it show indatabase as long as it shows normally in php page ,
after changing the php page to utf8 , when adding input than retriving it , if show result as it should .
but the old data which was added before converting the page encoding to uft8 show like this : �����
i tried a lot of methods for fixis this like using iconv in ssh and php , utf8_decode() utf8_encode() .. and more but none worked .
so i was hoping that you have a solution for me here ?
update :: Main goal was solved by retrieving data from php page in old encoding ' windows-1256' than update it from ssh .
but one issue left ::
i have some text that was inserted as 'windows-1256' and other that was inserted as 'utf-8' so now the windows encoding was converted to utf-8 and works fine , but the original utf-8 was converted as well to something unreadable , using iconv in php, with old page encoding ..
so is there a way to check what encoding is original in order to convert or not ?
Try run query set name utf8 after create a DB connection, before run any other query.
Such as :
$dbh = new PDO('mysql:dbname='.DB_NAME.';host='.DB_HOST, DB_USER, DB_PASSWORD);
$dbh->exec('set names utf8');
I'm currently using this function to obfuscate a bit the field values in MySQL and protect it from direct dumping. It all works good and values are stored correctly, but what happens when i try to store a multibyte string?
Here's an example, let's try to encode the string álex:
<?
$v = xorencode('álex');
// step 1 - encode
echo $v."\n";
// step 2 - decode
echo xorencode($v);
?>
Works good, i see some obfuscated string first time, and then i see álex again. Now if i try to save it in a VARCHAR field in a MySQL table, and then select it - i no longer have a utf string, instead it gets returned as gllex.
Note, MySQL tables and fields collations are utf8_general_ci, files are UTF-8, and i SET NAMES utf8 after connecting. Any workaround to this?
Thanks