luabind 导出string问题
luabind导出字符串 不能导出char* 会有问题 应该是字符串连接的时候出错了
static _TCHAR* pRetChar = new _TCHAR[10];
memcpy(pRetChar,szName,10);
return NetE::wtoutf8(pRetChar); //WCharToMultiByte 为什么就不可以那?
std::string wtoutf8 ( const wchar_t *wstr )
{
std::string str = "";
if ( NULL == wstr ) return str;
size_t wlen = wcslen(wstr);
if ( wlen >= 1020 ) wlen = 1020; // 防止溢出
unsigned char obuff[1024] = "";
unsigned char *t = obuff;
wchar_t *us = const_cast<wchar_t*>(wstr);
int UNICODE_CHARS = (sizeof(wchar_t) >= 4 ? 0x110000 : 0x10000);
for (size_t i = 0; i < wlen; i++)
{
wchar_t mychar = us[i];
if (mychar <= 0x7F)
{
*t++ = mychar; /* 7 sig bits */
}
else if (mychar <= 0x7FF)
{ /* 11 sig bits */
*t++ = 0xC0 | (unsigned char) (mychar >> 6); /* upper 5 bits */
*t++ = 0x80 | (unsigned char) (mychar & 0x3F); /* lower 6 bits */
}
else if (mychar <= 0xFFFF)
{ /* 16 sig bits */
*t++ = 0xE0 | (unsigned char) (mychar >> 12); /* upper 4 bits */
*t++ = 0x80 | (unsigned char) ((mychar >> 6) & 0x3F); /* next 6 bits */
*t++ = 0x80 | (unsigned char) (mychar & 0x3F); /* lowest 6 bits */
}
else if (mychar < UNICODE_CHARS)
{ /* 21 sig bits */
*t++ = 0xF0 | (unsigned char) ((mychar >> 18) & 0x07); /* upper 3 bits */
*t++ = 0x80 | (unsigned char) ((mychar >> 12) & 0x3F); /* next 6 bits */
*t++ = 0x80 | (unsigned char) ((mychar >> 6) & 0x3F); /* next 6 bits */
*t++ = 0x80 | (unsigned char) (mychar & 0x3F); /* lowest 6 bits */
}
}
str = (char*)obuff;
return str;
}
luabind 导出string问题的更多相关文章
- KindEditor的内容以Word的形式导出
//导出按钮 protected void btn_Export_Click(object sender, EventArgs e) { Model.article ...
- springMVC导出 CSV案例
导出csv 第一步 Controller类里调用 OrderParamsVo 传入的参数 orderService.findBuyCSV 查询到要导出的信息 /** * 购买订单CSV * Order ...
- Exel 利用模板导出方法
#region Exel导出方法 [MaxuniAuthAttribute(Roles = "sysroles")] public void OrderExport(string ...
- java导出数据Excel总结
//创建获取到JFileChooser的文件名的JTextField public JTextField getTextField(Container c){ JTextField textField ...
- 用java8重写Arrays.sort(oldWay, new Comparator<String>(){@Override public int compare(String s1, String s2)});
参考https://www.liaoxuefeng.com/article/001411306573093ce6ebcdd67624db98acedb2a905c8ea4000/ Java 8终于引进 ...
- C#调用Delphi DLL获取字符串(C# IntPtr 与 string互转 )
前因后果 调用一门锁的dll实现读取酒店IC卡数据,直接用Readme里的方法出错. 函数声明: 一.读卡函数 ************************ Delphi 调用 ****** ...
- JAVA导出Excel(支持多sheet)
一.批量导出: /** * * @Title: expExcel * @Description: 批量导出客户信息 * @param @param params * @param @param req ...
- jsp导出到Excel
jsp模板文件 <%@ page isELIgnored="false" contentType="application/x-msdownload; charse ...
- 将DataTable中的数据导出成Excel
public bool ExportFile(System.Data.DataTable dt){ SaveFileDialog sfd = new SaveFileDialog(); s ...
随机推荐
- 学习Perl6: slice fastq file
需求: 只获取 ath 物种的 hairpin 序列 文件格式如下所示,以>打头的为 header,紧跟的为序列[AUCG]+ (Perl5 regexp 格式) #!/usr/bin/env ...
- struts2结果类型
struts2结果类型: 结果类型 描述 前request域属性是否丢失 1 dispatcher 用于与jsp整合的结果类型.默认结果类型. 2 chain Action链式处理结果类型.前一个Ac ...
- 自定义Exception
本文改编自http://blog.csdn.net/stellaah/article/details/6738424 [总结] 1.自定义异常: class 异常类名 extends Exceptio ...
- Hibernate,JPA注解@Version
Hibernate实现悲观锁和乐观锁. 1,悲观锁 用例代码如下: 数据库DDL语句: hibernate.cfg.xml java类 以上代码(除下面的main之外)同乐观锁. main packa ...
- js词法作用域规则
function foo() {console.log( a ); // 2不是3} function bar() {var a = 3;foo();} var a = 2;bar(); js中的作用 ...
- 【转】MySQL5安装的图解(mysql-5.0.27-win32.zip)
转载地址:http://blog.csdn.net/xssh913913/article/details/1713182 MySQL5安装的图解(最新版) http://hi.baidu.com/yu ...
- VI 命令简介
1.打开一个文件 vi 文件路径 2.命令模式转换 输入模式 i 命令模式 esc 3.复制 和 粘贴 1)将光标移动到将要复制的行处,按yy进行复制当前行(按nyy复制n行),再移动到粘贴位 ...
- 从invoke简单理解反射
前言 程序集 : 程序集是.NET应用程序的基本单位,包含了程序的资源.类型元数据和MSIL代码.根据程序集生成方式的不同,可分为静态程序集和动态程序集.程序集又可分为单文件程序集和多文件程序集, ...
- SlickGrid example 3a: 可编辑单元
可编辑单元支持一列展示多个属性域,可以为编辑单元提供验证,并且自定义验证事件. 代码: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 T ...
- 使用存储过程来动态调用数据(SELECT)
USE [MyTestDb] GO /****** Object: StoredProcedure [dbo].[PROC_GetChannelList] Script Date: 04/09/201 ...