How to decode base64 (to little endian) with PHP?

How can I decode a base64 encoded message in PHP? I know how to use the PHP_base64_decode function, but I want to know how to write a small endian part, for example the code below is base64 code with a little endian: (how to write a small endian part in php)

Original Base64 content (as posted by original poster) :

https://stackoverflow.com/revisions/viewmarkup/374860

-1


source to share


2 answers


Use base64_decode () .



+4


source


Base64 converts a stream of bytes to printable characters. There is nothing bad.

"Little end" describes one of two ways: a number can be converted to a sequence of bytes: first-endian = least significant byte. Big-endian = high byte. UTF-8 is a string encoding into a byte stream and there is an assertion concept to apply. UTF16, however, encodes text into 16-bit words, and there are two ways to encode words into bytes, and UTF16 comes in two flavors, UTF16LE (small end) and UTF16BE (big end). The same concept of endianness also applies to UTF32, but this is not a generic format.

If by little-endian you mean UTF16LE, then you need to decide what format you want to recode the string in (probably UTF-8).
You can use this function: mb_convert_encoding($input, 'UTF-8', 'UTF-16LE')

[1] [2]



If by unfamiliar you mean numbers, then you need to specify the continent at any point at which you convert bytes to numbers.

[1] http://cz.php.net/manual/en/function.mb-convert-encoding.php
[2] http://cz.php.net/manual/en/mbstring.supported-encodings.php

+2


source







All Articles