src/Punycode/Punycode.php
public function ucs2Encode($codePoints)
    {
        $outStr = '';
        foreach ($codePoints as $v) {
            if( 0x10000 <= $v && $v <= 0x10FFFF) {
                $v -= 0x10000;
                $w1 = 0xD800 | ($v >> 10);
                $w2 = 0xDC00 | ($v & 0x03FF);
                $outStr .= chr(0xFF & ($w1 >> 8)) . chr(0xFF & $w1);
                $outStr .= chr(0xFF & ($w2 >> 8)) . chr(0xFF & $w2);
            }else{
                $outStr .= chr(0xFF & ($v >> 8)) . chr(0xFF & $v);
            }
        }
        return $outStr;
    }
public function ucs2Encode($codePoints)
    {
        $outStr = '';
        foreach ($codePoints as $v) {
            if( 0x10000 <= $v && $v <= 0x10FFFF) {
                $v -= 0x10000;
                $w1 = 0xD800 | ($v >> 10);
                $w2 = 0xDC00 | ($v & 0x03FF);
                $outStr .= chr(0xFF & ($w1 >> 8)) . chr(0xFF & $w1);
                $outStr .= chr(0xFF & ($w2 >> 8)) . chr(0xFF & $w2);
            }else{
                $outStr .= chr(0xFF & ($v >> 8)) . chr(0xFF & $v);
            }
        }
        return $outStr;
    }
public function ucs2Encode ( $ codePoints ) { $ outStr = '' ; foreach ( $ codePoints as $ v ) { if ( 0x10000 <= $ v && $ v <= 0x10FFFF ) { $ v -= 0x10000 ; $ w1 = 0xD800 | ( $ v >> 10 ) ; $ w2 = 0xDC00 | ( $ v & 0x03FF ) ; $ outStr .= chr ( 0xFF & ( $ w1 >> 8 ) ) . chr ( 0xFF & $ w1 ) ; $ outStr .= chr ( 0xFF & ( $ w2 >> 8 ) ) . chr ( 0xFF & $ w2 ) ; } else { $ outStr .= chr ( 0xFF & ( $ v >> 8 ) ) . chr ( 0xFF & $ v ) ; } } return $ outStr ; }
Creates a string based on an array of numeric code points.
@see `punycode->ucs2Decode`
@param array $codePoints The array of numeric code points.
@returns string The new Unicode string (UCS-2).
Creates a string based on an array of numeric code points .