遇到文字內有 ♥ 等 HTMLEntities
在 MSSql 需要 encode 才能儲存
但現在 MySql 已經可以一直接存放 ♥ = ♥
在Ruby 有好用的gme 可以直接轉換
HTMLEntities
https://github.com/threedaymonk/htmlentities
範例
Decoding
require 'htmlentities'
coder = HTMLEntities.new
string = "élan"
coder.decode(string) # => "élan"
Encoding
This is slightly more complicated, due to the various options. The encode method takes a variable number of parameters, which tell it which instructions to carry out.
require 'htmlentities'
coder = HTMLEntities.new
string = "<élan>"
Escape unsafe codepoints only:
coder.encode(string) # => "<élan>"
Or:
coder.encode(string, :basic) # => "<élan>"
沒有留言:
張貼留言