gpt4 book ai didi

ios - 当我在 XCode iOS 中触发推送通知时出现奇怪的字符

转载 作者:行者123 更新时间:2023-11-29 00:18:48 25 4
gpt4 key购买 nike

当我用阿拉伯语触发本地通知时,我遇到了一个奇怪的角色。结果显示错误字符,如下图所示。

enter image description here

请注意,该句子已打包到阿拉伯语本地化 Plist 文件。 Plist 和其他 cpp 文件编码为 UTF-8...这是 Plist 文件的 parcelling 代码

以及下面PushLocalNotif的功能

PushLocalNotif((CCLocalizedString("Notif1"), 2);


void PushLocalNotif(const char* string,int day) {
UILocalNotification *notification = [[UILocalNotification alloc]init];
notification.repeatInterval = NSDayCalendarUnit;
[notification setAlertBody:[NSString stringWithFormat:@"%s",string]];
//[notification setFireDate:[NSDate dateWithTimeIntervalSinceNow:60*60*24*day]];
[notification setFireDate:[NSDate dateWithTimeIntervalSinceNow:60/* * 60 * day*/]];
[notification setTimeZone:[NSTimeZone defaultTimeZone]];
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
}

以及带有 notif 语句的本地化 plist 文件。 enter image description here

我确定错误与编码字符有关,但我找不到编码该句子的方法:(

最佳答案

尝试改为[notification setAlertBody: [NSString stringWithCString:string encoding:NSUTF8StringEncoding]];

关于ios - 当我在 XCode iOS 中触发推送通知时出现奇怪的字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44584410/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com