私はcoreDataからエンティティをフェッチし、fetchrequestの結果をNSMutableStringに保存してスピーチを行います。NSMutableStringと(文字)エンコーディングの問題:üの場合は U00fcを取得
self.ttsInboxCards = [[NSMutableString alloc] initWithString:@""];
[self.ttsInboxCards appendString:[[entitySetsCards valueForKey:@"cardTitle"] description]];
とのNSLogで、私は、この値を取得しています:
でなければなりませんF\U00fcr | schl\U00e4ge | zuh\U00f6ren
:
Für | schläge | zuhören
私はと、たとえば、正しいエンコーディングを取得するために多くのことを試してみました:
stringWithUTF8String:
それでも、何も働かなかった。
どうすればこの問題を防ぐことができますか?
EDIT 1:
私はこのようなcoreDataから値を取得しています:
NSFetchRequest * fetchRequest = [[[NSFetchRequestのalloc]のinit] autoreleaseの]。
NSEntityDescription *entity = [NSEntityDescription entityForName:@"EntitySetsCardsInbox" inManagedObjectContext:self.managedObjectContext];
[fetchRequest setEntity:entity];
NSPredicate *inboxPred = [NSPredicate predicateWithFormat:@"archived == 0 AND cardId != 0"];
[fetchRequest setPredicate:inboxPred];
NSSortDescriptor *sortDescriptor2 = [[[NSSortDescriptor alloc] initWithKey:sortString ascending:sortAsc selector:@selector(localizedCaseInsensitiveCompare:)] autorelease];
NSArray *sortDescriptors = [[[NSArray alloc] initWithObjects:sortDescriptor2, nil] autorelease];
[fetchRequest setSortDescriptors:sortDescriptors];
NSError *error = nil;
NSArray *cardTitles = [self.managedObjectContext executeFetchRequest:fetchRequest error:&error];
[self.ttsInboxCards appendString:[[cardTitles valueForKey:@"cardTitle"] description]];
テキスト読み上げ
if (isSpeaking) {
[vocalizer cancel];
isSpeaking = NO;
}
else {
isSpeaking = YES;
vocalizer = [[SKVocalizer alloc] initWithLanguage:@"de_DE" delegate:self];
[vocalizer speakString:tmp];
}
それを見つけることができますか?それが文字列なら、なぜあなたは '-description'を呼び出していますか?文字列そのものを使うことができます。 –
文字列です。私が 'description'を削除すると、** NSInvalidArgumentException '、reason:' - [__ NSArrayI length]:** – brush51
待ちます。 'cardTitles'は配列です。そこで、 '-valueForKey:'を呼び出すと、各要素に対して '-valueForKey:@" cardTitle "'を呼び出すことで構築された配列が生成されます。それから、あなたはその配列についてその説明を求めています。そのコンテンツのフォーマットを行う可能性が非常に高いです。あなたは実際にその表現で何を達成しようとしていますか? –