Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. <?php
  2. private function handleTextFrame($frameSize, $raw)
  3. {
  4. $data = unpack('C1encoding/A' . ($frameSize - 1) . 'information', $raw);
  5.  
  6. if ($data['encoding'] == 0x00) # ISO-8859-1
  7. return mb_convert_encoding($data['information'], 'utf-8', 'iso-8859-1');
  8. else{ # utf-16
  9. # Fix the missing last char of the info bug
  10. # Add NUL character at the end of the string.
  11. # Don't ask, just enjoy. Idk why it works, but it works!
  12. $data["information"] .= chr(0);
  13. return mb_convert_encoding($data['information'], 'utf-8', 'utf-16');
  14. }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement