Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 555 Vote(s) - 3.49 Average
  • 1
  • 2
  • 3
  • 4
  • 5
UTF-8 all the way through

#11
In my case, I was using `mb_split`, which uses regular expressions. Therefore I also had to manually make sure the regular expression encoding was UTF-8 by doing `mb_regex_encoding('UTF-8');`

As a side note, I also discovered by running `mb_internal_encoding()` that the internal encoding wasn't UTF-8, and I changed that by running `mb_internal_encoding("UTF-8");`.


Reply

#12
> **Warning:** This answer applies to PHP 5.3.5 and lower. Do not use it for PHP version 5.3.6 (released in March 2011) or later.
>
> Compare with [Palec's answer to _PDO + MySQL and broken UTF-8 encoding_](

[To see links please register here]

).

---

I found an issue with someone using [PDO][1] and the answer was to use this for the PDO connection string:

$pdo = new PDO(
'mysql:host=mysql.example.com;dbname=example_db',
"username",
"password",
array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));

[1]:

[To see links please register here]

Reply

#13
The only thing I would add to these amazing answers is to emphasize on saving your files in UTF-8 encoding, I have noticed that browsers accept this property over setting UTF-8 as your code encoding. Any decent text editor will show you this. For example, [Notepad++][1] has a menu option for file encoding, and it shows you the current encoding and enables you to change it. For all my PHP files I use UTF-8 without a [BOM][2].

Sometime ago I had someone ask me to add UTF-8 support for a PHP and MySQL application designed by someone else. I noticed that all files were encoded in ANSI, so I had to use [iconv][3] to convert all files, change the database tables to use the UTF-8 character set and *utf8_general_ci* collate, add 'SET NAMES utf8' to the database abstraction layer after the connection (if using 5.3.6 or earlier. Otherwise, you have to use charset=utf8 in the connection string) and change string functions to use the PHP multibyte string functions equivalent.

[1]:

[To see links please register here]

[2]:

[To see links please register here]

[3]:

[To see links please register here]



Reply

#14
I have just gone through the same issue and found a good solution at PHP manuals.

I changed all my files' encoding to UTF8 and then the default encoding on my connection. This solved all the problems.

if (!$mysqli->set_charset("utf8")) {
printf("Error loading character set utf8: %s\n", $mysqli->error);
} else {
printf("Current character set: %s\n", $mysqli->character_set_name());
}

[View Source][1]

[1]:

[To see links please register here]



Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through