馬上給分,繁體字轉換為簡體字問題?

MiracleAizw 2007-11-30 09:06:36
首先添加引用Microsoft.VisualBasic;
string abc = Microsoft.VisualBasic.Strings.StrConv("問題", VbStrConv.SimplifiedChinese, 0);

得到的abc怎么還是"問題",而不是"问题" ,為什么呢?
...全文
167 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
Me866 2008-08-21
  • 打赏
  • 举报
回复
ghdfgh
曲滨_銘龘鶽 2007-11-30
  • 打赏
  • 举报
回复
如果不是简体中文系统 StrConv 最后一个参数给 0 会系统会使用如下代码取得 LCID


Thread.CurrentThread.CurrentCulture.LCID
曲滨_銘龘鶽 2007-11-30
  • 打赏
  • 举报
回复
楼主不是简体中文系统吧?
曲滨_銘龘鶽 2007-11-30
  • 打赏
  • 举报
回复
这个也好用啊,楼主为何说不好用?

int lcid = 0x0804;
Console.WriteLine(Microsoft.VisualBasic.Strings.StrConv("问题", VbStrConv.TraditionalChinese, lcid));
Console.WriteLine(Microsoft.VisualBasic.Strings.StrConv("問題", VbStrConv.SimplifiedChinese, lcid));

曲滨_銘龘鶽 2007-11-30
  • 打赏
  • 举报
回复


using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace BigCn
{
class Program
{
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern int LCMapString(int Locale, int dwMapFlags, byte[] lpSrcStr, int cchSrc,[Out] byte[] lpDestStr, int cchDest);

   const int LCMAP_SIMPLIFIED_CHINESE = 0x02000000;

   const int LCMAP_TRADITIONAL_CHINESE = 0x04000000;

static void Main(string[] args)
{

Console.WriteLine(
StringConv("问题", LCMAP_TRADITIONAL_CHINESE)
);

Console.WriteLine(
StringConv("問題", LCMAP_SIMPLIFIED_CHINESE)
);
}



public static string StringConv(string chars, int LCMP_CONST)
{

   Encoding ec = Encoding.Unicode;

byte[] src = ec.GetBytes(chars);

   byte[] dest = new byte[src.Length];

int r = LCMapString(0x0804, LCMP_CONST, src, -1, dest, src.Length);

   return ec.GetString(dest);

   }


}
}
liuyun1987 2007-11-30
  • 打赏
  • 举报
回复
public string toSimplifiedChinese(string sText)
{
return Microsoft.VisualBasic.Strings.StrConv(sText, VbStrConv.SimplifiedChinese);
}
vicqqq 2007-11-30
  • 打赏
  • 举报
回复
using  System;
using System.IO;
using System.Text;
using System.Runtime.InteropServices;
public class EncodeTool
{

[DllImport("kernel32.dll", EntryPoint = "LCMapStringA")]
public static extern int LCMapString(int Locale, int dwMapFlags, byte[] lpSrcStr, int cchSrc, byte[] lpDestStr, int cchDest);

const int LCMAP_SIMPLIFIED_CHINESE = 0x02000000;
const int LCMAP_TRADITIONAL_CHINESE = 0x04000000;

public static String ConvertString(String lines){
Encoding gb2312 = Encoding.GetEncoding(936);
byte[] src=gb2312.GetBytes(lines);
byte[] dest = new byte[src.Length];
LCMapString(0x0804, LCMAP_SIMPLIFIED_CHINESE, src, -1, dest, src.Length);
return gb2312.GetString(dest);
}
}
vicqqq 2007-11-30
  • 打赏
  • 举报
回复
public static extern int LCMapString(int Locale, int dwMapFlags, byte[] lpSrcStr, int cchSrc, byte[] lpDestStr, int cchDest);
vicqqq 2007-11-30
  • 打赏
  • 举报
回复
const int LCMAP_SIMPLIFIED_CHINESE = 0x02000000;
const int LCMAP_TRADITIONAL_CHINESE = 0x04000000;
vicqqq 2007-11-30
  • 打赏
  • 举报
回复
[DllImport("kernel32.dll", EntryPoint = "LCMapStringA")]
MiracleAizw 2007-11-30
  • 打赏
  • 举报
回复
LCMapString是什么函數?
vicqqq 2007-11-30
  • 打赏
  • 举报
回复
  public  static  String  ConvertString(String  lines)
{
Encoding gb2312 = Encoding.GetEncoding(936);
byte[] src=gb2312.GetBytes(lines);
byte[] dest = new byte[src.Length];
LCMapString(0x0804, LCMAP_SIMPLIFIED_CHINESE, src, -1, dest, src.Length);
return gb2312.GetString(dest);
}
grearo 2007-11-30
  • 打赏
  • 举报
回复
帮顶,期待中。。。
MiracleAizw 2007-11-30
  • 打赏
  • 举报
回复
我是想將繁體轉化為簡體,
vicqqq 2007-11-30
  • 打赏
  • 举报
回复
Dim xx, yy As String
xx = "見過了"
yy = Microsoft.VisualBasic.StrConv(xx,VbStrConv.TraditionalChinese,0)
在Excel使用过程中,运用一些技巧会使得我们的工作效率提高很多。而这些技巧往往又被忽略或忘记怎么去使用。本套课程基于此整理了一些Excel方面的技巧,这些呢为学习笔记集锦,前后章内容不存在连贯性,仅整理一些常用的技巧与大家分享。l  本课程知识点l  第1节:概述、使用excel必会技巧之隐藏自己的工作表l  第2节:excel单元格任意区域禁止输入重复值设置技巧l  第3节: 一键快速删除工作表重复数据l  第4节:追踪所引用的单元格,查找数据来源l  第5节: 自动查找工作表中的错误数据l  第6节:快速在单元格中创建下拉按钮,内容直接选择不需输入l  第7节: 自动选择不重复的数据并复制到指定位置l  第8节:光标进入单元格时自动弹出提示内容l  第9节: 使用特殊符号将单元格内容分列并复制到指定区域l  第10节: Excel鼠标模式和触摸模式自由切换l  第11节:快速冻结首行和首列单元格l  第12节: 将打印预览和打印添加到快捷操作栏上l  第13节: 在录入日期的时候限制日期范围,错误则弹出提示l  第14节: Excel内置的屏幕截图工具操作方法l  第15节:插入注册商标符号及特殊符号l  第16节:在Excel工作表中插入艺术并对艺术特殊效果处理l  第17节: 对excel工作表中的多列数据同时排序l  第18节: 将选定的区域放大到恰好容纳位置l  第19节:按姓名或中文汉笔画进行排序l  第20节: 按单元格颜色进行排序l  第21节:excel按行也可以排序l  第22节: excel中的数据快速条件筛选l  第23节:巧妙删除带有空格的单元格所在的行的内容l  第24节: 巧用辅助列进行筛选l  第25节:对中文汉繁体和简体快速转换l  第26节: 隐藏最近使用的文件列表l  第27节:使用图标或等级符号标记单元格l  第28节: 自动套用主题单元格样式l  第29节: 插入超链接删除超链接l  第30节:绘图格式形状效果形状轮廓

110,545

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧