develooper Front page | perl.perl5.porters | Postings from October 2008

Please check if this small code snippet looks correct

From:
karl williamson
Date:
October 29, 2008 17:42
Subject:
Please check if this small code snippet looks correct
Message ID:
490902CC.7010401@khwilliamson.com
As I'm new to all this, I want to make sure this is the right way to 
create a scalar value containing a single arbitrary unicode codepoint, 
in utf8.  uv is a UV containing the ordinal value to store.

U8 string[UTF8_MAXBYTES+1];
U8 *tmps;
SV *sv_str;

tmps = uvuni_to_utf8(string, uv);
sv_str = newSVpvn_utf8((char*)string, tmps - string, TRUE);


I believe this works even if the code point is NUL.

thanks



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About