(str: string)
| 154 | } |
| 155 | // overlong & range checks (simple) |
| 156 | if ( |
| 157 | !valid || |
| 158 | (needed === 1 && cp < 0x80) || |
| 159 | (needed === 2 && cp < 0x800) || |
| 160 | (needed === 3 && cp < 0x10000) || |
| 161 | cp > 0x10ffff || |
| 162 | (cp >= 0xd800 && cp <= 0xdfff) |
| 163 | ) { |
| 164 | cps.push(REPLACEMENT); |
| 165 | } else { |
| 166 | cps.push(cp); |
| 167 | } |