也许您可以使用一些不太可能的分隔符来指定数据缓冲区中编码切换的点。这将使您的解析函数识别必须以不同方式处理的文件块。
我不知道您的阿拉伯文本是否使用 UTF-8 字符。希望能够以 UTF-8 格式呈现英语和阿拉伯语中所有必需的字符。然后,您可以使用分隔符告诉其他代码如何处理行为不同的文本片段。
>some english/L-T-R markup
Ⓐ**...markup R-T-L Some**كل الخارجي للنص أو شكل توضع الفقرات في الصفحة التي يقرأها. ولذلك يتم استخدام طريقة لوريم إيبسوم لأنها تعطي توزيعاَ طبيعياَ -إلى حد ما- للأحرف عوضاً عن استخدام "هنا يوجد محتوى نصي، هنا يوجد محتوى نصي" فتجعلها تبدو (أي الأحرف) وكأنها نص مقروء. العديد من برامح النشر المكتبي وبرامح تحرير صفحات الويب تستخدم لوريم إيبسوم بشكل إفتراضي كنموذج عن اⒶ
不知道关于正则表达式,希望 github 上已经有处理混合阿拉伯语和英语正则表达式的库了:)
编辑:Stack Overflow 的 markdown 第一次吃了一些东西(天知道它对我粘贴的阿拉伯语 lorem ipsum 做了什么)
编辑:这是查找阿拉伯语标签的开始
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>' ]