doucheng3811 2015-03-11 10:46
浏览 71

使用PHP在MSSQL中存储UTF-8文本

What I'm trying to do is saving UTF-8 text to MSSQL db with PHP.

I know that MSSQL is not so cool with UTF-8. But I get strange results.

  • In SQL Server Management Studio (SSMS) I open edit table data screen and insert Cyrillic and Arabic characters into a field. They seem to be saved correctly. It takes one byte per character. I view it on SSMS just fine, but when I pull it from PHP it gives gibberish.

  • In PHP I use INSERT syntax to save the same data as above. It saves fine and when I select it back, it prints correct UTF-8 data just as it was inserted. But this time it looks gibberish on SSMS. And takes two bytes per character.

My Question: Is this normal? Is this what all people get with PHP + MSSQL + UTF-8? Shall I swallow the fact that it takes two bytes per character, unreadable via SSMS... This is correct?

Screenshot

enter image description here

  • First row was inserted via PHP. Reads fine from PHP, gibberish to SSMS.
  • Second row was inserted via SSMS. Prints gibberish when selected by PHP.
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 救!ENVI5.6深度学习初始化模型报错怎么办?
    • ¥30 eclipse开启服务后,网页无法打开
    • ¥30 雷达辐射源信号参考模型
    • ¥15 html+css+js如何实现这样子的效果?
    • ¥15 STM32单片机自主设计
    • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
    • ¥15 不小心不正规的开发公司导致不给我们y码,
    • ¥15 我的代码无法在vc++中运行呀,错误很多
    • ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。
    • ¥60 fail to initialize keyboard hotkeys through kernel.0000000000