Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you write Perl 6 scripts using an encoding that is not utf8?

Tags:

encoding

raku

Perl 5 has the encoding pragma or the Filter::Encoding module, however, I have not found anything similar in Perl 6. I guess eventually source filters will be created, but for the time being, can you use other encodings in Perl 6 scripts?

like image 532
jjmerelo Avatar asked Oct 05 '18 05:10

jjmerelo


2 Answers

You cannot write your Perl 6 script in anything except utf8. I don't think there will ever be any other encoding you will be allowed to write your script in, as utf8 is basically the universal standard. Benefits like not having endianess and being back compatible with ASCII are some reasons it has become the standard and not things like utf16 or utf32.

Maybe there was a time before when such a thing may have been useful, but today I do not see that being the case. All text editors in common usage I know of default to utf8, and having files in multiple formats makes it more difficult to share your Perl 6 programs with others. There are plenty of reasons to want to use other encodings external to Perl 6 (writing to files, reading files etc.) but I don't see adding filters as smart move.

like image 155
Samantha M. Avatar answered Sep 17 '22 15:09

Samantha M.


Rakudo currently supports an --encoding= option, so you might in theory be able to write a script in a different character encoding, and call it with perl6 --encoding=utf16 yourscript.p6. But in my experiments, I haven't managed to get it working with anything except utf8, and even if it worked, specifying --encoding on the command line would be a big no go for me.

So the operational answer is: currently no.

(And I don't think anybody else has asked for it yet...)

like image 29
moritz Avatar answered Sep 19 '22 15:09

moritz