Questions tagged [mb-convert-encoding]

46 questions
8
votes
1 answer

How can I convert "Western (Mac OS Roman)" formatted text to UTF-8 with PHP?

I have files being exported by Excel for Mac 2011 VBA in Western (Mac OS Roman) as shown here: I haven't been successful in getting Excel for Mac VBA to export directly to UTF-8 so I want to convert these files with PHP before I save them to MySQL,…
Edward Tanguay
  • 189,012
  • 314
  • 712
  • 1,047
7
votes
1 answer

How to normalize encoding names, like ks_c_5601-1987 to CP949?

I am fetching emails from a mail server and converting the message to UTF-8 charset and save it in DB.To convert the charset I am using mb_convert_encoding but it fails to convert gb2312 and ks_c_5601-1987. On googling I found that instead of…
Nidhi Kaushal
  • 299
  • 4
  • 15
4
votes
1 answer

PHP base64_decode! "@" comes out as a "¡"

I am pulling some code from an email (google) and it translates the code or encrypts it when I use an @ symbol it changes to and upside down explanation point.¡ I use the code below and it fixes it back to the @ symbol but it adds a "?" and the end…
Papa De Beau
  • 3,744
  • 18
  • 79
  • 137
4
votes
3 answers

How to keep the Chinese or other foreign language as they are instead of converting them into codes?

DOMDocument seems to convert Chinese characters into codes, for instance, 你的乱发 will become ä½ çš„ä¹±å‘ How can I keep the Chinese or other foreign language as they are instead of converting them into codes? Below is my simple test, $dom = new…
Run
  • 54,938
  • 169
  • 450
  • 748
3
votes
3 answers

Convert html entities to UTF-8, but keep existing UTF-8

I want to convert html entities to UTF-8, but mb_convert_encoding destroys already UTF-8 encoded characters. Whats the correct way? $text = "äöü ä ö ü ß"; var_dump(mb_convert_encoding($text, 'UTF-8', 'HTML-ENTITIES')); //…
user965306
3
votes
1 answer

Unexpected result from mb_detect_encoding with Windows-1252

I've read Wikipedia's article on Windows-1252 character encoding. For characters whose byte value is < 128, it should be the same as ASCII/UTF-8. This makes sense: php -r "var_export(mb_detect_encoding(\"\x92\", 'windows-1252', true));"…
Hut8
  • 6,080
  • 4
  • 42
  • 59
2
votes
0 answers

How to convert characters into hindi characters in PHP

I am trying to convert database column that is stored in utf8_unicode_ci collation to hindi characters. For example: दà¥à¤ƒà¤– का अधिकार- Quiz 1 This is not showing in hindi language, I even added after…
topper1309
  • 151
  • 3
  • 16
2
votes
0 answers

How to handle HTML with PHP's DOMDocument if the encoding of source HTML is unknown?

I just faced that HTML document encoded with UTF-8 becomes incorrect after loadHTML(). There are plenty of such QnA's on the Stack: PHP DomDocument failing to handle utf-8 characters PHP DOMDocument loadHTML not encoding UTF-8 correctly PHP DOM…
Vlada Katlinskaya
  • 991
  • 1
  • 10
  • 26
1
vote
1 answer

Need coldfusion version of php's sha1 and mb_convert_encoding

Does anyone know the coldfusion equivelent for this php code? $calcedVerify = sha1(mb_convert_encoding($pop, "UTF-8")); $calcedVerify = strtoupper(substr($calcedVerify,0,8)); Thanks!
pagex
  • 41
  • 1
1
vote
1 answer

Issue with php-curl windows-1253 encoding to utf8

I am using this code in order to show data onto php page: $url = 'http://example.com'; //Initiate cURL and pass it the URL we want to retrieve. $ch = curl_init($url); //Tell cURL to return the output as a string. curl_setopt($ch,…
John Greco
  • 45
  • 6
1
vote
0 answers

PHP UTF16 to UTF8 conversion

Tried to read UTF16 contents from CSV and convert it into UTF8 using mb_convert_encoding and do utf8_decode on the text. Now compare this text to the utf8_decoded text from webpage and write output to a xls.This works fine for almost all languages…
Anonymous
  • 11
  • 2
1
vote
1 answer

PHP: checking if string is utf-8 or utf-16le

I'm writing function that returns document in utf-8 by default, by if you provide special parameter it will return content in utf-16le. I started to write unit test for this function and what I don't understand is how to check if encoding is "utf-8"…
Tamara
  • 2,910
  • 6
  • 44
  • 73
1
vote
0 answers

ISO-8859-1 to UTF-8

The files in English are uploaded without any problem, but if I upload the format of a utf-8 format file, I will have an error like this: failed to open stream: Invalid argument. $file working. So I don't think it's a problem to change the format.…
firepunch
  • 89
  • 1
  • 5
1
vote
0 answers

How to modify mb_convert_case function for a locale language exception?

I convert titles to MB_CASE_TITLE case with: $title_of_post_case = mb_convert_case($title_of_post, MB_CASE_TITLE); However, there is an exception in our locale language: Lowercase of I letter is ı (not i). So, KALDIRIMLAR word converts to…
horse
  • 707
  • 4
  • 11
  • 30
1
vote
1 answer

Using mb_convert_encoding() to convert string from HTML-ENTITES to UTF-8 and back

I'd like to convert character encoding of a string to HTML-ENTITIES and then back to utf-8. I thought that converting to some encoding and back should leave me with the same string, but it doesn't look like it. My testing string is: Test:…
feek
  • 11
  • 4
1
2 3 4