Last active
August 7, 2019 16:34
-
-
Save parzibyte/592fb5d037e56f94e855f95a69b1766f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
private function handleTextFrame($frameSize, $raw) | |
{ | |
$data = unpack('C1encoding/A' . ($frameSize - 1) . 'information', $raw); | |
if ($data['encoding'] == 0x00) # ISO-8859-1 | |
return mb_convert_encoding($data['information'], 'utf-8', 'iso-8859-1'); | |
else{ # utf-16 | |
# Fix the missing last char of the info bug | |
# Add NUL character at the end of the string. | |
# Don't ask, just enjoy. Idk why it works, but it works! | |
$data["information"] .= chr(0); | |
return mb_convert_encoding($data['information'], 'utf-8', 'utf-16'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment