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.

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

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器