This channel is intended for people just starting with the Raku Programming Language (raku.org). Logs are available at irclogs.raku.org/raku-beginner/live.html
Set by lizmat on 8 June 2022.
lizmat and yet another Rakudo Weekly News hits the Net: rakudoweekly.blog/2025/01/20/2025-...-released/ 12:59
rcmlz Given a bitstring like 0101010001101111011011000110110000100001 which is utf-8 of some Unicode characters, how could I convert that to the caracters? 13:21
assert ...("0101010001101111011011000110110000100001") == "Toll!" assert ...("01001000 11000011 10100100 00111111") == "Hä?" 13:27
lizmat m: say "0101010001101111011011000110110000100001".parse-base(2) 13:28
camelia 362646629409
lizmat m: my $zo = "0101010001101111011011000110110000100001"; my $b = Buf.new; $b.write-bits(0,$zo.chars,$zo.parse-base(2)); dd $b.decode 13:31
camelia "Toll!"
rcmlz Thank you very much! 13:32
antononcube Hmm... these number base questions/answers make me consider publishing a Number theory related post. 13:34
I might do it today, since it is a holiday here. 13:35
rcmlz My students shall transform bitstrings manually to characters - I just x-checking my master solution ;-) 13:39
Anton, ist that Number theory? We do that under the label "Introduction, Data, Representation, Codings" 13:41
... but I was confident, that Raku has a one-liner for me ...
and was not disapointed. thanks to Liz. 13:42
antononcube I implemented in "Math::NumberTheory" the functions: - digit-count - integer-exponent - real-digits - phi-number-system which are related to number-base conversions. 13:44
Yes, Raku has some nice built-in Number theory functions, like, base, mod, polymod, is-prime. They somewhat lack generality, hence I made the functions mentioned above. 13:45
rcmlz ok, than "bitstring to character" might be a good fit too. 13:46
antononcube I think I have to write a few posts with "Math::NumberTheory", and / or make "neat examples" videos, in order to show what can be done. 13:47
My biggest "problem" is that I am not a Number theory fan (let alone expert), hence many of my implementations have only the basic, easy to understand algorithms and not most efficient ones. 13:48
It seems "bitstring-to-character" is a "lower level" function than what "Math::NumberTheory" deals with. (But maybe it is not.) 13:51
BTW, the built-in complex- and bignum arithmetic of Raku makes it a very good language to extend with Number theory functions. 13:53