0

Is there any simple way in PHP 5 to convert from unicode code points such as

U+1F9DB, U+200D, U+2642, U+FE0F

to a byte sequence

  F0  9F  A7  9B,   E2  80  8D,   E2  99  82,   EF  B8  8F
\xf0\x9f\xa7\x9b  \xe2\x80\x8d  \xe2\x99\x82  \xef\xb8\x8f

There are tables, but I assume, there's an easier way?

BurninLeo
  • 4,240
  • 4
  • 39
  • 56
  • "simple" refers to "not hack the full stack to implement the logic behind UTF-8", see https://stackoverflow.com/questions/6240055/manually-converting-unicode-codepoints-into-utf-8-and-utf-16 – BurninLeo Jul 08 '19 at 12:16
  • You should be using PHP7 by now. PHP5 is end of life and has been for a good while. – Martin Jul 08 '19 at 12:17
  • I am, but not all of the people using my software ;) But, yes, if there's no simple solution, I shall make a few people angry. – BurninLeo Jul 08 '19 at 12:20
  • 1
    Choose between making them angry or by using insecure and unmaintained software. PHP has a host of security and efficiency issues that have been fixed over the last 15 years; and now PHP5 is no longer maintained, certain hackers will be specifically working on breaching PHP5 because of things like your business who have it and have not yet updated it. [read more](https://dev.to/david_j_eddy/php-5-end-of-life-is-upon-us-why-you-should-care-3gpk) – Martin Jul 08 '19 at 12:27

0 Answers0