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 ...
随机推荐
- JVM学习笔记(二)------Java代码编译和执行的整个过程【转】
转自:http://blog.csdn.net/cutesource/article/details/5904542 版权声明:本文为博主原创文章,未经博主允许不得转载. Java代码编译是由Java ...
- oracle 11g 64w 用32位的pl/sql
1. 下载64位Oracle,解压两文件,解压完成后将文件合并,安装: 2. 下载PL/SQL,安装: 3. 下载instantclient-basic-win32-11.2.0.1.0.zip ...
- post 405 method not allowed
HTTP 405 错误 – 方法不被允许 (Method not allowed) 介绍 HTTP 协议定义一些方法,以指明为获取客户端(如您的浏览器或我们的 CheckUpDown 机器人)所指定的 ...
- 启动hadoop报192.168.1.151: Address 192.168.1.151 maps to node1, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT!
使用root用户启动hadoop的时候报错: [root@node1 ~]# su - hadoop -c start-all.sh starting namenode, logging to /ap ...
- 12、Jsp加强/自定义标签/JavaBean
1 Jsp加强回顾 Jsp加强 1)Jsp的9大内置对象 request HttpServletRequet response HttpServletResponse config ...
- CSS 学习质料
1.学习CSS布局 http://zh.learnlayout.com/display.html
- CMake快速入门教程:实战
转自http://blog.csdn.net/ljt20061908/article/details/11736713 0. 前言 一个多月前,由于工程项目的需要,匆匆的学习了一下cmake的使 ...
- python:正则表达式 re
#re正则的用法:match匹配从开头 search 取一个就回来了,findout取所以匹配的,slit分割 sub替换 #-*- coding:utf8 -*- # Auth:fulimei #r ...
- 20150601_Andriod 打开新窗体
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="htt ...
- Codeforces Round #337 Vika and Segments
D. Vika and Segments time limit per test: 2 seconds memory limit per test: 256 megabytes input ...