For windows-1256 / cp1256 support, could be interesting to look into this code: https://github.com/khaled-alshamaa/ar-php/blob/master/src/Arabic.php At the section Convert Arabic string into glyph joining in UTF-8 hexadecimals stream. For other code pages, this code is used: $data = ...