Issue writing tag in a different language - somebody please help
Stephen F. Booth
me at sbooth.org
Tue Mar 25 11:48:06 UTC 2014
Just for posterity, a more general approach for converting NSString * or
CFStringRef to a TagLib::String is posted below. It could be made more
efficient with a stack buffer of a fixed size and iterative conversion but
this works well enough.
TagLib::String TagLib::StringFromCFString(CFStringRef s)
{
if(nullptr == s)
return String::null;
CFRange range = CFRangeMake(0, CFStringGetLength(s));
CFIndex count;
// Determine the length of the string in UTF-8
CFStringGetBytes(s, range, kCFStringEncodingUTF8, 0, false, nullptr,
0, &count);
char *buf = new char [count + 1];
// Convert it
CFIndex used;
CFIndex converted = CFStringGetBytes(s, range, kCFStringEncodingUTF8,
0, false, (UInt8 *)buf, count, &used);
if(CFStringGetLength(s) != converted)
;
// Add terminator
buf[used] = '\0';
String result(buf, String::UTF8);
delete [] buf;
return result;
}
On Mon, Mar 24, 2014 at 10:57 PM, Anand <flashanand at gmail.com> wrote:
> Found the correct syntax - Thanks Patrick
>
> tag->itemListMap()["\251nam"] =
> TagLib::StringList(TagLib::String([@"ஜில்லுனு ஒரு காதல்"
> cStringUsingEncoding:NSUTF8StringEncoding],TagLib::String::UTF8));
>
>
> On Sun, Mar 23, 2014 at 8:26 AM, Anand <flashanand at gmail.com> wrote:
>
>> Hi,
>>
>> I think the syntax is wrong for obj-c.
>>
>> But i think we are in right direction.
>>
>> Thanks
>> Anand
>>
>>
>>
>>
>> On Sun, Mar 23, 2014 at 5:01 AM, patrick machielse <patrick at hieper.nl>wrote:
>>
>>> Op 22 mrt. 2014, om 17:05 heeft Anand <flashanand at gmail.com> het
>>> volgende geschreven:
>>>
>>> > I am trying to tag the title of an .m4v using TagLib like this
>>> >
>>> > tag->itemListMap()["\251nam"] = TagLib::StringList([@“Bolt”
>>> cStringUsingEncoding:NSUTF8StringEncoding]);
>>> >
>>> > It works because “Bolt” is in English. But the following doesn’t work
>>> - since it is in different language - any body knows why?
>>> >
>>> > tag->itemListMap()["\251nam"] = TagLib::StringList([@“ஜில்லுனு ஒரு
>>> காதல்” cStringUsingEncoding:NSUTF8StringEncoding]);
>>>
>>> I think you need to specify the encoding when you create the String /
>>> StringList:
>>>
>>> For instance:
>>>
>>> mp4tag->setTitle(String([@"ஜில்லுனு ஒரு காதல்" UTF8String],
>>> String::UTF8));
>>>
>>> constructors without a specific encoding Type assume Latin1.
>>>
>>> p.
>>> --
>>> Patrick Machielse
>>> Hieper Software
>>>
>>> http://www.hieper.nl
>>> info at hieper.nl
>>>
>>>
>>
>
> _______________________________________________
> taglib-devel mailing list
> taglib-devel at kde.org
> https://mail.kde.org/mailman/listinfo/taglib-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/taglib-devel/attachments/20140325/b105f7c0/attachment.html>
More information about the taglib-devel
mailing list