[英]Escape a single quote sign in highcharts
I'm working on a Rails app and have a serie name "Helen's book" which is shown on the chart as Helen '
我正在开发一个Rails应用程序并且有一个系列名称“Helen的书”,在图表中显示为Helen
'
s book. 的书。
I tried to use gsub method in the controller but it didn't work out: 我试图在控制器中使用gsub方法,但它没有成功:
@results[:data].each{|result| x[:result].gsub("'", "\\\\'")}
How to achieve a properly shown single quote sign? 如何实现正确显示的单引号?
It is 2016. Use UTF-8 proper typographic apostrophe 这是2016年。使用UTF-8正确的印刷撇号
@results[:data].each do |result|
x[:result].gsub(/(?<=\W)['"]/, "‘")
.gsub(/['"](?=\W)/, "’")
.gsub("'", "’")
end
#⇒ Helen’s book
#⇒ Book ‘Adventures’
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.