CRISHK Corporation
CRISHK Corporation

Reputation: 3008

mb_detect_encoding ever is ASCII

$output = "ALLWILLBEASCII";
foreach ($output as $name => $value) {
    echo mb_detect_encoding( $value );
}

How to convert from ASCII to UTF-8 in PHP?

Upvotes: 2

Views: 2250

Answers (3)

FatherStorm
FatherStorm

Reputation: 7183

if a character is valid ASCII, it is valid UTF-8 there is nothing to convert. http://en.wikipedia.org/wiki/UTF-8

Upvotes: 3

simshaun
simshaun

Reputation: 21466

You can use mb_convert_encoding() or iconv() to convert character encoding.

Upvotes: 0

Gumbo
Gumbo

Reputation: 655159

The characters of ASCII are a subset of Unicode and the code words of ASCII are also valid UTF-8. So you need no conversion as every ASCII string is also a valid UTF-8 string (but not vice versa).

Upvotes: 2

Related Questions