[FFmpeg-devel] [RFC][PATCH] Windows Television (WTV) file system handling

Måns Rullgård mans
Sat Jan 22 14:22:12 CET 2011


Reimar D?ffinger <Reimar.Doeffinger at gmx.de> writes:

> On Sat, Jan 22, 2011 at 09:20:20PM +1100, Peter Ross wrote:
>> > > I do not know of any. While there are wchar functions, one cannot rely on
>> > > sizeof(wchar_t)==2.
>> > 
>> > If you insist on comparing strings, all strings being compared here
>> > are always static strings. This allows for tricks, e.g. declaring them
>> > as wchar_t strings, which you apparently don't want to do, or just
>> > creating one manually by doing "s\0t\0r\0i\0n\0g"; </ugly>. The
>> > advantage of these approaches (easiest is really to look for a
>> > wchar-style thing that ensures 16-bit unicode formatting) is that you
>> > can use memcmp() instead of this slow compare function, and memcmp()
>> > is probably better-optimized. Also saves code.
>> 
>> You're right, that looks horrid. I have updated to use wcscmp().
>
> I am not really very comfortable of getting into the compatibility
> nightmare of wchar_t.
> In particular I think you are assuming that wchar is compatible with
> UCS-2, but I think that there have been other wchar formats.

The C99 spec says this:

  [wchar_t] is an integer type whose range of values can represent
  distinct codes for all members of the largest extended character set
  specified among the supported locales; the null character shall have
  the code value zero and each member of the basic character set shall
  have a code value equal to its value when used as the lone character
  in an integer character constant.

This means wchar_t can be of any size, including 8 bits if only e.g.
iso-8859-1 is supported by the system.

-- 
M?ns Rullg?rd
mans at mansr.com



More information about the ffmpeg-devel mailing list