Is utf-8 suitable for type text / plain mime?

I export data through files. Base64 encoded data output.

$data = base64_encode(serialize($data));

This leads to something like:

bGFzcyI6MTp7czo1OiJzZXR1cCI7YTo3Mzp7czoyNToicGFnZXNfY29udGFjdF91c19oZWFkbGlu

So, I am wondering which encoding is more suitable for this data (plain text). us-ascii seems sufficient, but utf-8 always seems to be erroneous by default.

header('content-type: text/plain; charset=utf-8');
+5
source share
2 answers

It really doesn't matter; your content is valid US-ASCII, valid UTF-8, valid ISO-8859-1(or, I believe, any ISO-8859-x), valid Windows-1252, etc. Just don’t put UTF-16either EBCDICor something like that.

( , US-ASCII, Unicode, Unicode ISO-8859-1 whatnot, .)

+7

. 'text/plain' , .

, ascii, utf-8, latin1 ( ruakh), .

( downvotes, !)

@dan04: UTF-8 - , , . Base64 , base64 , . Base64 , US-ASCII ( , UTF-8 latin1/ISO-8859).

Base64 - , . , US-ASCII ( "" -, US-ASCII), .

Base64 mimetype. . (!)

, Base64 mimetype , , Content-Transfer-Encoding. , jpeg, .

Content-Type: image/jpeg
Content-Transfer-Encoding: base64 

, ( ), "generic binary", :

Content-Type: application/octet-stream
Content-Transfer-Encoding: base64 
+19

All Articles