drwurqczo39355510 2013-07-02 15:57
浏览 54
已采纳

传递给ServicedComponent(COM +)的MSSQL UTF8字符串,但使用PHP显示时输出变为大5

I stored my data in my MSSQL as UTF8 (I'm sure it is UTF8) and I use visual studio debug tool and I can see my string as UTF8 (because certain character only exit in UTF8, not big5), but after I use PHP to display my data through IIS fastCGI, the result is big5!.

I build a simple class to test it. You can try it.

using System.EnterpriseServices;
using System.Runtime.InteropServices;

namespace CoreService.HTML
{
    public interface ICore
    {        
        string get_string();
    }

    public class Core : ServicedComponent, ICore
    {
        public string get_string()
        {
            return "堃";
        }    
    }

}

If you get the character instead of ?? then you get it right. But I always get big after I call the COM+ in my PHP. I try apache and it is still the same thing.

UPDATE:

PHP sample code:

$object =  new COM("CoreService.HTML.Core") or die("Unable to instantiate CoreService COM object");
echo $object->get_string();

COM+ installation batch file: (install.bat)

cd\
c:
cd C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\
gacutil /i "c:\Fashion DLL\CoreService.dll"
echo install CoreService.dll Done
cd\
cd C:\Windows\Microsoft.NET\Framework\v4.0.30319
regsvcs /u "c:\Fashion DLL\CoreService.dll"
regsvcs "c:\Fashion DLL\CoreService.dll"
echo FashionCoreService done

in case you want to retry, you can use this to uninstall tlb file or the file is locked by IIS or apache:

cd\
c:
cd C:\Windows\Microsoft.NET\Framework\v4.0.30319
regsvcs /u "c:\Fashion DLL\CoreService.dll"
regasm /u "c:\Fashion DLL\CoreService.dll"
echo remove FashionCoreService done
iisreset
del "c:\Fashion DLL\CoreService.tlb"
pause
  • 写回答

1条回答 默认 最新

  • dongpou7275 2013-07-04 01:32
    关注

    I found the solution.

    $object = new COM("CoreService.HTML.Core", null, 65001) or die("Unable to instantiate CoreService COM object"); echo $object->get_string();

    the third parameter is the codepage parameter, just assign 65001 (utf-8) then PHP will connect COM using UTF-8.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 matlab计算中误差
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊