ios – 按字符串删除所有重音符号

ios – 按字符串删除所有重音符号,第1张

概述surnameField.text = "Fal à èà ò l'opo"; // remove space and apostropheNSString *surnarmeInput = [[surnameField.text stringByReplacingOccurrencesOfString:@" " withString:@""] stringByReplacingOcc
surnameFIEld.text = "Fal à èà ò l'opo";    // remove space and apostropheNsstring *surnarmeinput = [[surnameFIEld.text stringByReplacingOccurrencesOfString:@" " withString:@""] stringByReplacingOccurrencesOfString:@"'" withString:@""];

我也会删除重音符号.

结果“Falaeaolopo”

解决方法
// convert to a data object,using a lossy conversion to ASCIINSData *asciIEncoded = [yourOriginalString dataUsingEnCoding:NSASCIIStringEnCoding                         allowLossyConversion:YES];// take the data object and recreate a string using the lossy conversionNsstring *other = [[Nsstring alloc] initWithData:asciIEncoded                                        enCoding:NSASCIIStringEnCoding];// relinquish ownership[other autorelease];

这将删除所有的重音.删除所有空格

Nsstring *yourFinalString = [other stringByReplacingOccurrencesOfString:@" " withString:@""];

删除重音的第一部分,从this线程中的dreamlax的答案复制的代码..

总结

以上是内存溢出为你收集整理的ios – 按字符串删除所有重音符号全部内容,希望文章能够帮你解决ios – 按字符串删除所有重音符号所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1007157.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存