为了方便帖名侦探柯南事务所的发布代码,于是写了个简单的程序:
在写程序的过程中得到FA很多帮助,下面有一个一个比较有意思的代码,简体繁体字形转换就是FA提供的。该代码调用的系统dll。
[codes=csharp]
// **************************************************************
// CovEncoding (2007-06-10)
//
// Copyright (C) 2006 FalconIA
//
// http://falconia.ca/
//
// **************************************************************
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace APTXCODE
{
public class Conver
{
#region String mapping flags
///
///
const int LCMAP_LOWERCASE = 0x00000100;
///
///
const int LCMAP_UPPERCASE = 0x00000200;
///
///
const int LCMAP_SORTKEY = 0x00000400;
///
///
const int LCMAP_BYTEREV = 0x00000800;
///
///
const int SORT_STRINGSORT = 0x00001000;
///
///
const int LCMAP_HIRAGANA = 0x00100000;
///
///
const int LCMAP_KATAKANA = 0x00200000;
///
///
const int LCMAP_HALFWIDTH = 0x00400000;
///
///
const int LCMAP_FULLWIDTH = 0x00800000;
///
///
const int LCMAP_LINGUISTIC_CASING = 0x01000000;
///
///
const int LCMAP_SIMPLIFIED_CHINESE = 0x02000000;
///
///
const int LCMAP_TRADITIONAL_CHINESE = 0x04000000;
#endregion
public enum ChsChtType { CHS, CHT };
[DllImport(“kernel32.dll”, EntryPoint = “LCMapStringW”, CharSet = CharSet.Auto)]
static extern int LCMapString(
int Locale,
int dwMapFlags,
string lpSrcStr,
int cchSrc,
string lpDestStr,
int cchDest
);
public static string ConvChsCht(string srcString, ChsChtType chType)
{
string dstString = new string(' ', srcString.Length);
int mapFlags = 0;
switch (chType)
{
case ChsChtType.CHS:
mapFlags = LCMAP_SIMPLIFIED_CHINESE;
break;
case ChsChtType.CHT:
mapFlags = LCMAP_TRADITIONAL_CHINESE;
break;
}
LCMapString(0x0804, mapFlags, srcString, -1, dstString, srcString.Length * 2);
return dstString;
}
public static string ConvChsToCht(string srcString)
{
return ConvChsCht(srcString, ChsChtType.CHT);
}
}
}
[/codes]
1 Responses to APTX发布代码生成工具