以下内容不起作用
subject = "The amount of £#{@amount} has been sent to your account".html_safe
mail(:to => @email, :subject => subject, :reply_to => 'support@xyz.com')也没有
subject = "The amount of £#{@amount} has been sent to your account".html_safe我怎样才能在电子邮件的主题上显示英镑标志?
发布于 2013-09-09 15:22:44
电子邮件主题(作为电子邮件中的所有标题)不接受网页上使用的HTML实体。相反,它们对非ASCII数据使用几种不同的编码,所有这些编码都应该由mail gem自动应用。
因此,可能最简单的方法是直接将字符放入subject变量中,而不需要自己应用任何额外的编码:
subject = "The amount of £#{@amount} has been sent to your account"
mail(:to => @email, :subject => subject, :reply_to => 'support@xyz.com')请注意,除非您使用Ruby2.0(默认为utf-8源代码编码iirc),否则您可能必须将magic encoding comment放在源文件的顶部,以便Ruby能够将源代码解释为类似于此的UTF-8。
# encoding: UTF-8https://stackoverflow.com/questions/18701120
复制相似问题