寻找字符串操作的边缘情况。 我需要测试什么?
我正在进入我的绳索(String
的更具可扩展性的版本)实现的最后阶段。 显然,我希望所有操作尽可能给出与 String 上的操作相同的结果。
对序数操作执行此操作非常简单,但我担心能否正确实现文化敏感操作。 特别是因为我只知道两种语言,并且在这两种语言中,文化敏感操作的行为与序数操作完全相同!
那么有什么具体的事情我可以测试并至少对我做的事情有一定的信心吗? 例如,我知道,当忽略德语中的大小写时,ß 等于 SS; 关于土耳其语中带点和不带点的 i。
I am getting to the last stage of my rope (a more scalable version of String
) implementation. Obviously, I want all operations to give the same result as the operations on String
s whenever possible.
Doing this for ordinal operations is pretty simple, but I am worried about implementing culture-sensitive operations correctly. Especially since I know only two languages and in both of them culture-sensitive operations behave precisely the same as ordinal operations do!
So are there any specific things that I could test and get at least some confidence that I am doing things correctly? I know, for example, about ß being equal to SS when ignoring cases in German; about dotted and undotted i in Turkish.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
代理对,如果您计划支持它们 - 包括无效组合(例如,仅其中的一部分)。
如果您正在进行编码和解码,请确保保留足够的状态来应对要解码的任意二进制数据块,这些数据块可能会在一个字符的中途结束,而剩余的一半将出现在下一个字符中。
Surrogate pairs, if you plan to support them - including invalid combinations (e.g. only one part of one).
If you're doing encoding and decoding, make sure you retain enough state to cope with being given arbitrarily blocks of binary data to decode which may end half way through a character, with the remaining half coming in the next character.
土耳其语测试是我所知道的最好的:)
The Turkish test is the best I know :)
您应该模仿 String 方法实现并使用核心库来为您完成此操作。 考虑到每种文化的每一个可能的方面是非常困难的。 不要重新发明轮子,而是在 String 方法上使用反射器并查看内部调用。 例如,String.Compare 使用 CultureInfo.CurrentCulture.CompareInfo.Compare 来比较当前区域性中的 2 个字符串。
You should mimic the String methods implementations and use the core library to do this for you. It is very hard to take into account every possible aspect of every culture. Instead of re-inventing the wheel use reflector on the String methods and see the internal calls. For example String.Compare uses CultureInfo.CurrentCulture.CompareInfo.Compare for comparing 2 strings in current culture.