New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
XS converts to UTF-8 but not back #6001
Comments
From jacob.mandelson@overture.comPassing strings to XS native methods converts them to UTF-8, but Testcase: Trivial XS method: Calling this with: gives: Perl Info
|
From nick.ing-simmons@elixent.comJacob.Mandelson@Overture.Com <perl5-porters@perl.org> writes:
Passing the string to XS does nothing to it at all. Given the XS code I don't see how to do better - going from an SV to a char *
|
From jacob.mandelson@overture.com
There is apparently the convention that the octets passed in to XS are With the present asymmetry, how do you propose to return strings from native |
From @jhiAs Nick Ing-Simmons, I do not see an easy way out here. The lone char * passed in to the XS simply doesn't carry enough information. The XS cannot know whether the char * contains eight-bit bytes or UTF-8 encoded data (or, if using modules like Encode, bytes of any other encoding, like UTF-16, or Latin-2, or ShiftJIS, or KOI8-R, or...). One must pass in whole SVs, that way one can at least test for SvUTF8(sv), which would indicate that the data is in UTF-8, and one can use the APIs described in perlguts. After Perl 5.8.0 there's been a patch for perlunicode that also explains Unicode/UTF-8 for XS writers: http://public.activestate.com/cgi-bin/perlbrowse?filename=&action=patch&patch=17959&.submit=Submit&.cgifields=action |
@jhi - Status changed from 'new' to 'resolved' |
Migrated from rt.perl.org#17848 (status was 'resolved')
Searchable as RT17848$
The text was updated successfully, but these errors were encountered: