Skip Menu |

This queue is for tickets about the Data-JavaScript CPAN distribution.

Report information
The Basics
Id: 8591
Status: resolved
Priority: 0/
Queue: Data-JavaScript

People
Owner: jpierce [...] cpan.org
Requestors: SREZIC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.08
Fixed in: (no value)



Subject: Handling of Unicode characters
Data::JavaScript currently has no support for characters above codepoint 0xff. For example, the script use Data::JavaScript; print join("\n", jsdump("unicode", "\x{20ac}")), "\n"; would return a string with three bytes, the utf-8 representation of 0x20ac. However, it would be safer if \u20ac would be used instead. Here's a possible solution: sub quotemeta { my $text = shift; $text =~ s/([^\x20\x21\x23-\x26\x28\x7E\x{0100}-\x{fffd}])/sprintf("\\%03o", ord($1))/ge; $text =~ s/([\x{0100}-\x{fffd}])/sprintf("\\u%04x", ord($1))/ge; $text; } Regards, Slaven
Should be included in to be released Real Soon Now update using: s<([\x{0100}-\x{fffd}]+)>{sprintf(join('', '\u%04x' x length($1)), map{ord}split//,$1)}ge;