|
01:45
sibl joined
02:06
sibl left
02:20
sibl joined
02:54
topnep left
02:57
topnep joined
03:24
topnep left
03:26
topnep joined
03:57
topnep_ joined
04:01
topnep left
05:49
sibl left
05:56
sibl joined
06:01
sibl left,
topnep_ left
06:02
sibl joined,
topnep joined
07:55
modula joined
|
|||
| modula | Hi. I'm trying to do this: gather { for (^100) { my $c = (0x20..0xFFFF).pick; try { $c = $c.chr; CATCH { next } }; take $c; } } but even though I have this wrapped in a `try` and `CATCH`, I still get errors like "Error encoding UTF-8 string: Could not encode Surrogate codepoint 55551". All I want is to run `next` to skip the current iteration if `$c.chr` throws any error. Why does this not | 08:00 | |
| work, and how can I make it work? | |||
|
08:06
topnep left
08:07
topnep joined
08:42
sivoais left
|
|||
| librasteve | hi modula | 11:02 | |
| let me see what I can make of that | |||
| hmmm - the error seems to be happening at the output stage (I prepended say to your code) | 11:18 | ||
|
11:18
sibl left
|
|||
| - I tried forcing the stringification inside the try block with $c = $i.chr.Str | 11:19 | ||
| but that did not improve matters - maybe someone more expect than I can help? | |||
| sorry | 11:20 | ||
| lizmat | modula: that's very perl like code :-) | 11:34 | |
| fwiw, that code doesn't fail for me | |||
| which version of rakudo are you using ? | |||
| ah... need a "dd" in front to make it fail | 11:35 | ||
| could it be that it is just an invalid code point that was picked ? | 11:38 | ||
| hmm.. looks like the .chr error is not trappable | 11:40 | ||
| m: .say with try 56792.chr | |||
| camelia | Error encoding UTF-8 string: could not encode Unicode Surrogate codepoint 56792 (0xDDD8) in block <unit> at <tmp> line 1 |
||
| lizmat | modula: golfed your code to: | 11:43 | |
| m: gather { for (0x20..0xFFF).pick(100) { .take with try .chr } } | |||
| camelia | ( no output ) | ||
| lizmat | m: dd gather { for (0x20..0xFFF).pick(100) { .take with try .chr } } | ||
| camelia | ("", "ݰ", "", "ଲ", "ԁ", "Æ", "Ƃ", "Ν", "", "\x[81D]", "", "", "ɕ", "ੋ", "ؤ", "Ӓ", "\x[59B]", "ˈ", "", "\x[749]", "Ǯ", "ໜ", "ۏ", "మ", "܉", "प", "", "", "ࡢ", "ಽ", "ৣ", "ໍ", "", "۾", "\x[ECB]", "… | ||
| lizmat | will make an issue for 56792.chr not being trappable | ||
| hmmm.. as librasteve noted, it's really in the stringification | 11:53 | ||
| m: say 56792.chr.ord | |||
| camelia | 56792 | ||
| lizmat | m: try say 56792.chr # trappable indeed | 11:56 | |
| camelia | ( no output ) | ||
|
14:03
sibl joined
14:07
sibl left
15:26
hudo left
15:28
guestll joined
15:37
Guest96 joined
15:53
Guest96 left
16:25
guestll left
16:32
sivoais joined
|
|||