Jar*_*ede 8 coldfusion json coldfusion-9
我在ColdFusion和JSON方面遇到了一些问题.我的用户有文件名和其他关键字ç,其中包含像我们这样的字符,当我必须通过JSON传回它们时,这会让我感到痛苦.
当我在我的变量上使用魔术JSON命令时:
<cfcontent type="application/json">
<cfset variables.stGalleryItem = StructNew() />
<cfset variables.stGalleryItem["imagePath"] = siteRoot & '/images/350460/hellç.txt' />
<cfset variables.stGalleryItem["title"] = 'çççç' />
<cfset variables.stGalleryItem["author"] = 'HI' />
<cfset variables.stGalleryItem["text"] = 'aa' />
<cfset ArrayAppend(variables.arrGallery,variables.stGalleryItem) />
<cfoutput>
#Trim(SerializeJSON(variables.arrGallery))#
</cfoutput>
Run Code Online (Sandbox Code Playgroud)
吐出的角色是 ,没有任何好处.
有什么我可以做的来保护我的用户ç吗?
您需要在CFCONTENT标记中指定字符集.我在没有字符集的谷歌浏览器中尝试了此代码,它正确地返回了文本.但是,FireFox 3.6返回了您列出的错误字符.
这正确地返回Chrome,FireFox和MSIE中的UTF-8字符:
<cfcontent type="application/json; charset=utf-8">Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2814 次 |
| 最近记录: |