从右到左的语言和编程问题 [英] right to left languages and programming problems

查看:70
本文介绍了从右到左的语言和编程问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个使用我创建的新语言(如BBcode)的Web文本编辑器.这种标记语言将使用阿拉伯语,但我面临以下问题:

I am creating a web text editor that uses a new language I created (like BBcode). This markup language will be in Arabic but I am facing these problems :

  • 在所有IDE和编辑器中,很难在同一行中混合使用英语和阿拉伯语文本,因为会发生奇怪的事情(单词和字符的顺序会发生变化)
  • 当使用模式用javascript替换文本时,阿拉伯文本不会出现 (例如:"1 text arabic here 1".replace(/1(*)1/,"($1)")我空了())
  • It's really hard to mix English and Arabic text in the same line in all IDE's and editors, because strange things happen (the order of words and characters changes)
  • when replacing a text with javascript using a pattern the Arabic text doesn't appear (eg: "1 text arabic here 1".replace(/1(*)1/,"($1)") I get empty () )

我该如何解决?

推荐答案

也许您可以使用一些不太可能使用的分隔符来指定数据缓冲区中编码转换的点.这样一来,您的解析功能就可以识别文件文件中需要区别对待的部分.

Perhaps you can use some unlikely deliminator character to specify points in your data buffers where your encoding switches. This would let your parsing functions identify chunks of your files that have to be treated differently.

我不知道您的阿拉伯文字是否使用UTF-8字符.希望可以在UTF-8中用英语和阿拉伯语呈现所有必需的字符.然后,您可以使用定界符告诉其他代码如何处理行为不同的文本.

I don't know if your arabic text uses UTF-8 characters. Hopefully it is possible to render all necessary characters in both english and arabic in UTF-8. Then you can use your delimiter to tell your other code how to handle pieces of text that behave differently.

>some english/L-T-R markup  
Ⓐ**...markup R-T-L Some**كل الخارجي للنص أو شكل توضع الفقرات في الصفحة التي يقرأها. ولذلك يتم استخدام طريقة لوريم إيبسوم لأنها تعطي توزيعاَ طبيعياَ -إلى حد ما- للأحرف عوضاً عن استخدام "هنا يوجد محتوى نصي، هنا يوجد محتوى نصي" فتجعلها تبدو (أي الأحرف) وكأنها نص مقروء. العديد من برامح النشر المكتبي وبرامح تحرير صفحات الويب تستخدم لوريم إيبسوم بشكل إفتراضي كنموذج عن اⒶ  

不知道正则表达式,希望github上已经有可以处理阿拉伯语和英语正则表达式的库了:)

Dunno about the regex, hopefully there are libraries on github that handle mixed arabic and english regex already :)

Stack Overflow的降价第一次吃了一些东西(上帝知道它对我粘贴的阿拉伯lorem ipsum做了什么)

edit: Stack Overflow's markdown ate some stuff the first time (and god knows what it did to my pasted arabic lorem ipsum)

这是查找阿拉伯语标记的开始

edit: here's a start to find the arabic tags

var src = "try to write javascript that replaces <رابط>نص تجريبي</رابط> by <a href='#'>نص تجريبي</a> and you wil notice all the difficulties – user2080105 15 mins ago"
var a = src.match(/try/);
console.log(a);
var b = src.match(/<[^>]*>/);
console.log(b);
var c = src.match(/<\/?[^>]*>/g);
console.log(c);

//Output in node v0.9.4-pre

[ 'try',
  index: 0,
  input: 'try to write javascript that replaces <رابط>نص تجريبي</رابط> by <a href=\'#\'>نص تجريبي</a> and you wil notice all the difficulties – user2080105 15 mins ago' ]
[ '<رابط>',
  index: 38,
  input: 'try to write javascript that replaces <رابط>نص تجريبي</رابط> by <a href=\'#\'>نص تجريبي</a> and you wil notice all the difficulties – user2080105 15 mins ago' ]
[ '<رابط>', '</رابط>', '<a href=\'#\'>', '</a>' ]

这篇关于从右到左的语言和编程问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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