Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. StringUnescaper.php

function StringUnescaper::codePointToUtf8

* Implementation based on https://github.com/nikic/PHP-Parser/blob/b0edd4c41111042d43bb45c6c657b2…

1 call to StringUnescaper::codePointToUtf8()
StringUnescaper::parseEscapeSequences in vendor/phpstan/phpdoc-parser/src/Parser/StringUnescaper.php
* Implementation based on https://github.com/nikic/PHP-Parser/blob/b0edd4c41111042d43bb45c6c657b2…

File

vendor/phpstan/phpdoc-parser/src/Parser/StringUnescaper.php, line 75

Class

StringUnescaper

Namespace

PHPStan\PhpDocParser\Parser

Code

private static function codePointToUtf8(int $num) : string {
    if ($num <= 0x7f) {
        return chr($num);
    }
    if ($num <= 0x7ff) {
        return chr(($num >> 6) + 0xc0) . chr(($num & 0x3f) + 0x80);
    }
    if ($num <= 0xffff) {
        return chr(($num >> 12) + 0xe0) . chr(($num >> 6 & 0x3f) + 0x80) . chr(($num & 0x3f) + 0x80);
    }
    if ($num <= 0x1fffff) {
        return chr(($num >> 18) + 0xf0) . chr(($num >> 12 & 0x3f) + 0x80) . chr(($num >> 6 & 0x3f) + 0x80) . chr(($num & 0x3f) + 0x80);
    }
    // Invalid UTF-8 codepoint escape sequence: Codepoint too large
    return "�";
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal