Commit 43bdcd6
fix: handle non-BMP Unicode codepoints in foldl, foldr, and %c format (#606)
This PR fixes two more non-BMP Unicode bugs:
- foldl/foldr iterated strings by UTF-16 code unit (`for (char <-
s.value)`), splitting non-BMP characters like emoji into surrogate pair
halves. Use `codePointAt`/`codePointBefore` with `Character.charCount`
for correct codepoint iteration.
- The `%c` format conversion used `s.toChar.toString` which truncates
codepoints above U+FFFF to 16 bits. Use `Character.toString(s.toInt)`
instead.
---
All code written by Claude Opus 4.6.
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 8430930 commit 43bdcd6
3 files changed
Lines changed: 42 additions & 5 deletions
File tree
- sjsonnet
- src/sjsonnet
- stdlib
- test/src/sjsonnet
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
199 | | - | |
| 199 | + | |
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
296 | 296 | | |
297 | 297 | | |
298 | 298 | | |
299 | | - | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
300 | 302 | | |
301 | | - | |
| 303 | + | |
| 304 | + | |
302 | 305 | | |
303 | 306 | | |
304 | 307 | | |
| 308 | + | |
305 | 309 | | |
306 | 310 | | |
307 | 311 | | |
| |||
324 | 328 | | |
325 | 329 | | |
326 | 330 | | |
327 | | - | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
328 | 336 | | |
329 | | - | |
| 337 | + | |
330 | 338 | | |
331 | 339 | | |
332 | 340 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
259 | 288 | | |
260 | 289 | | |
0 commit comments