[vlc-devel] [PATCH 1/1] freetype: handle non-English family and style names in Windows
Salah-Eddin Shaban
salah at videolan.org
Wed Nov 18 20:13:49 CET 2015
On Tue, Nov 17, 2015 at 11:19 PM, Jean-Baptiste Kempf <jb at videolan.org> wrote:
> From here:
>> + int i_length_in_wchars = i_name_length / 2;
>> + wchar_t *psz_name = malloc( ( i_length_in_wchars + 1 ) * sizeof( *psz_name ) );
>> +
>> + if( !psz_name )
>> + goto done;
>> +
>> + for( int i = 0; i < i_length_in_wchars; ++i )
>> + psz_name[ i ] = U16_AT( p_name + i * 2 );
>> + psz_name[ i_length_in_wchars ] = 0;
>> +
>> +#ifdef UNICODE
>> + psz_result = psz_name;
>> +#else
>> + psz_result = FromWide( psz_name );
>> + free( psz_name );
>> +#endif
>
> To here, this code seems a bit too complicated for what it does.
> And I'm not 100% sure that the code is always valid.
>
> Can't you use _tcsncpy and add the 0 at the end?
>
Not really.
The characters in p_name are big endian and _tcsncpy won't work with
little endian systems.
So the U16_AT is necessary.
> With my kindest regards,
>
> --
> Jean-Baptiste Kempf
> http://www.jbkempf.com/ - +33 672 704 734
> Sent from my Electronic Device
More information about the vlc-devel
mailing list