php decode base64 from UTF-16

I have string that create by mssql that base64 of utf-16 string:

SABlAGwAbABvACAAVwBPAHIAbABkAA==

The decoded version is :

Hello WOrld

This is .NET tools that can use be for decode http://www5.rptea.com/base64/ (Use UTF-16)

How can i convert this using php mb or base64 ?

This is my convertion that return wrong characters:

var_dump(mb_convert_encoding(base64_decode('SABlAGwAbABvACAAVwBPAHIAbABkAA=='), "UTF-8", "UTF-16"));

// string(33) "䠀攀氀氀漀 圀伀爀氀搀"

Upvotes: 0

Views: 1276

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799520

"UTF-16" is big endian, but your text is encoded little endian. Use "UTF-16LE" instead.

Upvotes: 1

Related Questions