[systemd-devel] [PATCH] shared: fix utf16_to_utf8() on big endian machines

Tom Gundersen teg at jklm.no
Wed Feb 18 06:11:23 PST 2015


On Wed, Feb 18, 2015 at 3:06 PM, Martin Pitt <martin.pitt at ubuntu.com> wrote:
> Hey Tom,
>
> Tom Gundersen [2015-02-18 14:34 +0100]:
>> I think we want to assume that we only get UTF-16LE, so it looks like
>> it is the test that is buggy. That's what we agreed, right Lennart?
>
> Ah, ok. Indeed GUID partition names are UTF16LE.
>
> I couldn't quickly find a reference for EFI variables (which is the
> main thing we are using this for), and I don't have/know a big-endian
> EFI machine to check this on. I found
>
>  http://uefi.blogspot.de/2009/12/uefi-hii-part-7-character-encoding.html
>
> which raises the endianness question (but doesn't answer it), and
> https://en.wikipedia.org/wiki/UTF-16 says both LE and BE are possible.
>
>> How about the attached patch?
>
> Confirmed to work on powerpc (BE) and x86_64 (LE). So if EFI variables
> are defined to be UTF16LE always, your patch is correct.

Thanks. Maybe Kay or Harald want to comment on the EFI question? For
JSON (the other use), we are always requiring LE (BE is possible, but
we'll detect that and refuse to load the file).

For now I'll push this patch as it confirms the test to be in line
with the code. If we need to add BE support we should do that
separately I guess.

Cheers,

Tom


More information about the systemd-devel mailing list