小编Has*_*aza的帖子

使用变量在本机反应中渲染 unicode 字符

我正在尝试呈现一些 Unicode 形式的阿拉伯语文本。

我已经尝试使用 Text 组件来渲染它,例如

const arabic  = "سُبْحَانَ اللهِ وَبِحَمْدِهِ"


render(){
 return(
  <Text>
   {arabic}
  </Text>
 )
}
Run Code Online (Sandbox Code Playgroud)

它按原样呈现 Unicode,但以这种方式编写

render(){
 return(
  <Text>

   &#1587;&#1615;&#1576;&#1618;&#1581;&#1614;&#1575;&#1606;&#1614;  
   #1575;&#1604;&#1604;&#1607;&#1616; 
 &#1608;&#1614;&#1576;&#1616;&#1581;&#1614;&#1605;&#1618;&#1583;&#1616; 
 &#1607;&#1616;

  </Text>
 )
}
Run Code Online (Sandbox Code Playgroud)

呈现正确的输出

javascript unicode reactjs react-native

12
推荐指数
1
解决办法
9241
查看次数

标签 统计

javascript ×1

react-native ×1

reactjs ×1

unicode ×1