How do I escape a Unicode string with Ruby?

前端 未结 6 902
春和景丽
春和景丽 2020-12-14 22:10

I need to encode/convert a Unicode string to its escaped form, with backslashes. Anybody know how?

6条回答
  •  眼角桃花
    2020-12-14 22:42

    try this gem. It converts Unicode or non-ASCII punctuation and symbols to nearest ASCII punctuation and symbols

    https://github.com/qwuen/punctuate

    example usage: "100٪".punctuate => "100%"

    the gem uses the reference in https://lexsrv3.nlm.nih.gov/LexSysGroup/Projects/lvg/current/docs/designDoc/UDF/unicode/DefaultTables/symbolTable.html for the conversion.

提交回复
热议问题