Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^4: Can someone please write a *working* JSON module (Send money)

by cnd (Acolyte)
on Oct 24, 2021 at 11:06 UTC ( #11137960=note: print w/replies, xml ) Need Help??


in reply to Re^3: Can someone please write a *working* JSON module (Send money)
in thread Can someone please write a *working* JSON module

newSVpvn_utf8 sounds awesome!. Is there some simple way to detect invalid UTF-8 ?

I guess something, somewhere, knows this - since croak() is the bane of my existence right now: email subject lines which may or may not have been truncated somewhere are 100% guaranteed to spew invalid UTF-8 at *some* point.

Is there some way perl can auto-magically handle UTF-16 as well? e.g. (from the RFC): "... UTF-16 surrogate pair. So, for example, a string containing only the G clef character (U+1D11E) may be represented as "\uD834\uDD1E"." (those 4 bytes (and/or 12 characters) are also an example of why truncated text breaks everything I expect)
  • Comment on Re^4: Can someone please write a *working* JSON module (Send money)

Replies are listed 'Best First'.
Re^5: Can someone please write a *working* JSON module (Send money)
by Corion (Pope) on Oct 24, 2021 at 11:22 UTC

    See Encode::Unicode for the translations between the various Unicode encodings.

    I think converting from UTF-16 to UTF-8 is merely a mathematical transformation between two encoding styles of the same number, so you can easily model that. I'm not sure how easy it is to determine whether a backslash-escaped sequence is UTF-8 or UTF-16, but maybe if it's just two characters, it's UTF-8.

    A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11137960]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2021-12-02 17:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    R or B?



    Results (23 votes). Check out past polls.

    Notices?