Unicode字符串无法正常工作 [英] Unicode string not working as expected

查看:67
本文介绍了Unicode字符串无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C ++程序(gpc程序裁剪器)和一个vb包装器.

我有一个问题.当我用"file.out"调用fopen时
因为string.fopen得到的是单词而不是字节的集合,并且感觉我只给出了1个字符,后跟一个空值.

如何管理cstyle字符串?

在vb.net中:
使用vb.net(dotnet)字符串(16位unicode)到预期8位字节字符串的c函数时出现问题
私有声明自动功能fopen Lib msvcr100.dll(ByVal fn作为字符串,ByVal模式作为字符串)作为IntPtr

I have a C++ program(the gpc program clipper) and a vb wrapper for it.

I have one problem in it. When i call fopen with a "file.out"
as string.fopen gets a collection of words instead of bytes and feels that I gave only 1 char followed by a null.

How do I manage to send a cstyle string?

in vb.net:
problem using vb.net(dotnet) string(16 bit unicode) to a c function expecting 8 bit byte string
Private Declare Auto Function fopen Lib msvcr100.dll (ByVal fn As String, ByVal mode As String) As IntPtr

推荐答案

在旧" vb中,您将使用StrConv.在VB.NET中,您应该使用Encoding类.请查看下面的链接.

http://msdn.microsoft.com/en-us/library/system.text. encoding.aspx [^ ]

祝你好运!
In "old" vb you would use StrConv. In VB.NET you should use the Encoding class. Have look at the link below.

http://msdn.microsoft.com/en-us/library/system.text.encoding.aspx[^]

Good luck!


我通过在fopen的Declare语句中将Ansi替换为Auto来管理它.
I managed it by replacing Auto by Ansi in the Declare statement for fopen.


这篇关于Unicode字符串无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆