替换C字符串中的字符 [英] Replace characters in C string

查看:95
本文介绍了替换C字符串中的字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出以下C字符串:

unsigned char *temp = (unsigned char *)[@"Hey, I am some usual CString" UTF8String]

如何用 other替换 usual以得到:嘿,我是其他CString。

How can I replace "usual" with "other" to get: "Hey, I am some other CString".

我不能使用 NSString 函数( replaceCharactersInRange / replaceOccurencesOfString 等)。我必须将所有内容保持在较低的水平,因为我要处理的字符串恰好超过5MB,因此在iOS设备上替换(大约需要做很多替换)大约需要10分钟。

I cannot use NSString functions (replaceCharactersInRange/replaceOccurencesOfString, etc.) for performance reasons. I have to keep it all at low level, since the strings I'll be dealing with happen to exceed 5MB, and therefore the replacements (there will be a lot of replacements to do) take about 10 minutes on a iOS device.

推荐答案

Objective-C只是C上的一薄层。
如果您需要使用本机C字符串,则只需

Objective-C is a just thin layer over C. If you need to work with native C strings, just go ahead and do it.

替换C中的字符串的功能是什么?

似乎可以很好地解决您的问题。

seems to address your problem fairly well.

这篇关于替换C字符串中的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆