如何创建在iOS中不是Unicode的下标字符 [英] How to create subscript characters that's not in Unicode in iOS

查看:81
本文介绍了如何创建在iOS中不是Unicode的下标字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试一段时间,创建一个带下标字符的NSString没有成功。是否甚至可以在iOS中执行此操作?

我需要一种方法来将字符串中的字符更改为下标或上标,并且不能使用Unicode作为Unicode,因为Unicode不具有所有

我的猜测可能是使用HTML标签< sub> < sup> 但我没有找到一种方法将所述HTML标签转换为NSString。

I've been trying for a while now to create a NSString with subscripted character without success. Is it even possible to do this in iOS?
I need a way to change characters in a string to subscript or superscript, and I can't use the Unicode for this as Unicode doesn't have all the letters.
My guess could be to use the HTML tags <sub> and <sup> but I haven't find a way to convert said HTML tags to a NSString.

推荐答案

下标和上标不是性格特征。除了少数例外(例如,2,3,ª),这是正常字符呈现的方式 - 以较小的字体和正常字符的基线之上/之下。考虑到这一点,你不能有一个带有下标字符的NSString,没有超过你可以有一个NSString加粗或斜体字符。

Subscript and superscript are not character traits. With few exceptions (e. g. ², ³, ª), this is the way regular characters are rendered - in a smaller font and above/below the regular characters' baseline. With this in mind, you cannot have an "NSString with subscripted characters", no more than you can have an NSString with bold or italic characters.

因此,除非在Unicode中存在所需的下标字符,否则下标和上标在字符串渲染时创建,而不是在字符串创建时创建。这不是iOS的限制,这是在现代计算机中处理字符串的方式的限制。

So as a result, unless the desired subscripted character exists in Unicode already, subscript and superscript is created on string rendering, not on string creation. And this is not a limitation of iOS, this is the limitation of the way strings are processed in modern computers.

你对这个NSString做什么?你在UILabel上显示它吗?你通过网络发送吗?是否将其呈现为HTML?注意,< sub> < sup> 除非NSString被具体解释为HTML(比如,通过UIWebView),它们不会被解释为sup / superscript。

What do you do to that NSString? Do you display it on a UILabel? Do you send it over the network? Do you render it as HTML? Note that <sub> and <sup> are HTML tags; unless the NSString is interpreted specifically as HTML (say, by a UIWebView), they won't be interpreted as sup/superscript.

这篇关于如何创建在iOS中不是Unicode的下标字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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