串联左右对齐的字符类型 [英] Concatenating left and right-aligned character types

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

问题描述

似乎字符类型的组合可能会为显式粘贴操作的结果顺序产生意外结果:

It seems that a combinations of character types can produce unexpected results for the resulting order of an explicit paste operation:

(x = paste(c('green','أحمر', 'أزرق'), collapse=' ')) # arabic for blue and red
#> [1] "green أحمر أزرق"
paste(x, 'yellow')
#> [1] "green أحمر أزرق yellow"
paste(x, 123)
#> [1] "green أحمر أزرق 123"

对此是否有任何已知的解决方案-即一种确保以与给出的参数相同的顺序进行串联的方法?也许答案是不要连接不同的字母

Is there any known solution to this - i.e. a way to ensure concatenation in the same sequence as the arguments are given? Perhaps the answer is don't concatenate different alphabets!

推荐答案

您可以使用Unicode控制字符从左到右嵌入" u202A(将以下文本作为从左到右嵌入"):

You may use the Unicode control characters 'left-to-right embedding', u202A ("Treat the following text as embedded left-to-right"):

paste(x, "\u202A", 123)
# [1] "green أحمر أزرق ‭ 123"


另请参见终止显式定向嵌入和覆盖,(u202C),a UNICODE双向算法


See also Terminating Explicit Directional Embeddings and Overrides, (u202C), a thorough description on UNICODE BIDIRECTIONAL ALGORITHM, and here.

这篇关于串联左右对齐的字符类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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