zoukankan      html  css  js  c++  java
  • Delphi单元文件之-简体繁体互转

    Function GBCht2Chs(GBStr: String): AnsiString; {GBK繁体转简体} Var   len:integer;   pGBCHTChar: PChar;   pGBCHSChar: PChar; Begin   pGBCHTChar := PChar(GBStr);   Len := SizeOf(pGBCHTChar);   GetMem(pGBCHSChar, Len  + 1);   ZeroMemory(pGBCHSChar, Len  + 1);

      //GB CHS -> GB CHT   LCMapString($804, LCMAP_SIMPLIFIED_CHINESE, pGBCHTChar, -1, pGBCHSChar, 2147483647 );

      Result := String(pGBCHSChar);   FreeMem(pGBCHSChar); End;

    //----------------------------------------------

    procedure TForm1.Button1Click(Sender: TObject); begin   Memo2.Text := GBCht2Chs( Memo1.Text ); end;

    unit BIG5TOGB; interface

    uses Windows;

    function GBCht2Chs(GBStr: string): AnsiString; function GBChs2Cht(GBStr: string): AnsiString;

    implementation

    function GBCht2Chs(GBStr: string): AnsiString; {进行GBK繁体转简体}  var Len: integer;  pGBCHTChar: PChar;  pGBCHSChar: PChar;  begin pGBCHTChar := PChar(GBStr);  Len := MultiByteToWideChar(936, 0, pGBCHTChar, -1, nil, 0); GetMem(pGBCHSChar, Len * 2 + 1);  ZeroMemory(pGBCHSChar, Len * 2 + 1);  //GB CHS -> GB CHT  LCMapString($804, LCMAP_SIMPLIFIED_CHINESE, pGBCHTChar, -1, pGBCHSChar, Len * 2);  result := string(pGBCHSChar); //FreeMem(pGBCHTChar);  FreeMem(pGBCHSChar);  end;

    function GBChs2Cht(GBStr: string): AnsiString; {进行GBK简体转繁体}  var Len: integer;  pGBCHTChar: PChar;  pGBCHSChar: PChar;  begin pGBCHSChar := PChar(GBStr);  Len := MultiByteToWideChar(936, 0, pGBCHSChar, -1, nil, 0); GetMem(pGBCHTChar, Len * 2 + 1);  ZeroMemory(pGBCHTChar, Len * 2 + 1);  //GB CHS -> GB CHT  LCMapString($804, LCMAP_TRADITIONAL_CHINESE, pGBCHSChar, -1, pGBCHTChar, Len * 2);  result := string(pGBCHTChar); FreeMem(pGBCHTChar);  //FreeMem(pGBCHSChar);  end; end.

  • 相关阅读:
    css 的包含块 、负外边距,字体,文本行高
    从Excel中读取数据(python-xlrd)
    准确率(Precision),召回率(Recall)以及综合评价指标(F1-Measure)
    K-means算法-聚类
    用线性回归寻找到最佳拟合直线
    python多线程--优先级队列(Queue)
    python多线程--线程同步
    python多线程
    元组操作
    input()和raw_input()
  • 原文地址:https://www.cnblogs.com/china1/p/3370925.html
Copyright © 2011-2022 走看看