开发者

What does u mean in regex?

开发者 https://www.devze.com 2023-03-20 17:48 出处:网络
I came across this code and I\'m at loss as to what u means : $todecode =~ s{ %u([Dd][89a-bA-B][0-9a-fA-F]{2}) # hi

I came across this code and I'm at loss as to what u means :

$todecode =~ s{
   %u([Dd][89a-bA-B][0-9a-fA-F]{2}) # hi
          %u([Dd][c-fC-开发者_Go百科F][0-9a-fA-F]{2})   # lo
        }{
     utf8_chr(
       0x10000_
       + (hex($1) - 0xD800) * 0x400_
       + (hex($2) - 0xDC00)
      )
        }gex;


It's the letter between t and v. (It's matching a literal u.)

It looks like somebody has some text with UTF-16 surrogate pairs written out as %uD800%uDC00, and they're passing the decoded codepoint to the utf8_chr function, and substituting the result of that.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号