1

my head is on the edge of exploding...
How can I encode my string to UTF-8?

I always get this error:
Arguments to text methods must be UTF-8 encoded

I use Prawn as PDF Writer.

4

2 回答 2

2

# encoding: utf-8

在您的 rb 文件的第一行。

于 2013-02-26T13:27:18.367 回答
1

你可以使用force_encoding

"some string".force_encoding("UTF-8")
于 2013-02-26T13:29:45.677 回答