stl字符串的便携式“小写”函数? [英] Portable 'lowercase' function for stl string?

查看:44
本文介绍了stl字符串的便携式“小写”函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在重写一些依赖某些平台/第三方

依赖实用程序功能的代码,因为我想要它更便携。

是否有一个标准的C / C ++ / stl例程,用于将stl字符串更改为所有

小写?

(我知道如何手动做,但为了便携性......)


谢谢


史蒂夫

解决方案

Steve Edwardsécrit:


我正在重写一些依赖某些平台/第三方的代码
依赖实用程序函数,因为我想让它更具可移植性。
是否有一个标准的C / C ++ / stl例程,用于将stl字符串更改为所有
小写?




我认为这取决于语言环境。

为了便携你可以使用你自己实现的那种

函数根据您选择的字符集(Unicode将

是一个很好的。)


loufoque写道:


我认为这取决于语言环境。
为了便携,你可以根据你选择的字符集使用你自己的那种
函数的实现(Unicode将是一个很好的。)



如果你的角色是用ASCII编码的
并且你关心速度,那么Unicode将是一个糟糕的选择。 Unicode中的大小写转换(并且只是

关于任何其他字符操作)可能相当慢,因为字符集的大小和由此产生的复杂性导致了b / b >
字符属性的数据表示(你真的不希望

来携带一堆64K阵列)。另一方面,使用ASCII,转换为小写的
只是一个测试和补充。


-


Pete Becker

Roundhouse Consulting,Ltd。


* Pete Becker:

loufoque写道:


我认为这取决于语言环境。
为了便携,你可以根据你选择的字符集使用你自己的那种
函数实现(Unicode如果你的角色用ASCII编码并且你关心速度,那么Unicode将是一个糟糕的选择。



由于字符集的大小以及由此产生的字符属性数据表示的复杂性,Unicode中的大小写转换(以及关于任何其他字符操作)只会很慢。你真的不想携带一堆64K阵列)。另一方面,使用ASCII,转换为小写只是一个测试和补充。




我认为这是不正确的。


为了说服我,你能不能给出一个例子

任意ASCII文本的转换必然比

同样的情况更快以固定的每个字符大小转换相同的文本

Unicode表示(例如USC2仅限于BMP或USC4)?


考虑ASCII是一个子集Unicode。


-

答:因为它弄乱了人们通常阅读文字的顺序。

问:为什么这么糟糕?

A:热门发布。

问:usenet和电子邮件中最烦人的是什么?


Hi,
I''m re-writing some code that had relied on some platform/third-party
dependent utility functions, as I want to make it more portable.
Is there a standard C/C++/stl routine for changing an stl string to all
lowercase?
(I know how to do it manually, but in the interests of portability...)

Thanks

Steve

解决方案

Steve Edwards a écrit :

Hi,
I''m re-writing some code that had relied on some platform/third-party
dependent utility functions, as I want to make it more portable.
Is there a standard C/C++/stl routine for changing an stl string to all
lowercase?



I think it depends on the locale.
To be portable you could use your own implementation of that kind of
functions according to the character set of your choice (Unicode would
be a good one).


loufoque wrote:


I think it depends on the locale.
To be portable you could use your own implementation of that kind of
functions according to the character set of your choice (Unicode would
be a good one).



Unicode would be a poor choice if, for example, your characters are
encoded in ASCII and you care about speed. Case conversions (and just
about any other character manipulation) in Unicode can be rather slow,
because of the size of the character set and the resulting complexity of
the data representation for character attributes (you really don''t want
to carry around a bunch of 64K arrays). With ASCII, on the other hand,
converting to lowercase is just a test and an addition.

--

Pete Becker
Roundhouse Consulting, Ltd.


* Pete Becker:

loufoque wrote:


I think it depends on the locale.
To be portable you could use your own implementation of that kind of
functions according to the character set of your choice (Unicode would
be a good one).



Unicode would be a poor choice if, for example, your characters are
encoded in ASCII and you care about speed. Case conversions (and just
about any other character manipulation) in Unicode can be rather slow,
because of the size of the character set and the resulting complexity of
the data representation for character attributes (you really don''t want
to carry around a bunch of 64K arrays). With ASCII, on the other hand,
converting to lowercase is just a test and an addition.



I think that''s incorrect.

To convince me otherwise, could you give an example where case
conversion of an arbitrary ASCII text is necessarily faster than the
same case conversion of the same text in fixed a size per character
Unicode representation (e.g. USC2 limited to BMP, or USC4)?

Consider that ASCII is a subset of Unicode.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?


这篇关于stl字符串的便携式“小写”函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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