zoukankan      html  css  js  c++  java
  • Delphi7中Unicode,ANSI,UTF编码问题

    注解:
      ANSI     'American Standard Code for Information Interchange' 美国信息互换标准代码 ANSI的'Ascii'编码
      Unicode 'Universal Multiple-Octet Coded Character Set' 简称 UCS, 俗称 'Unicode'
      UTF       'UCS Transfer Format'
      DBCS    'Double Byte Charecter Set' 双字节字符集

    相关重要函数过程:
    WinAPI:
      MultiByteToWideChar WideCharToMultiByte
      相关参数(CodePage)

        CP_ACP ANSI code page
        CP_MACCP Not supported
        CP_OEMCP OEM code page
        CP_SYMBOL Not supported
        CP_THREAD_ACP Not supported
        CP_UTF7 UTF-7 code page
        CP_UTF8 UTF-8 code page

    单元System.pas:
    function StringToWideChar(const Source: string; Dest: PWideChar; DestSize: Integer): PWideChar;
    function WideCharToString(Source: PWideChar): string;
    function WideCharLenToString(Source: PWideChar; SourceLen: Integer): string;
    procedure WideCharToStrVar(Source: PWideChar; var Dest: string);
    procedure WideCharLenToStrVar(Source: PWideChar; SourceLen: Integer; var Dest: string);

    type
      UCS2Char = WideChar; PUCS2Char = PWideChar;
      UCS4Char = type LongWord;
      UCS4String = array of UCS4Char;
    function PUCS4Chars(const S: UCS4String): PUCS4Char;
    function WideStringToUCS4String(const S: WideString): UCS4String;
    function UCS4StringToWideString(const S: UCS4String): WideString;

    function UnicodeToUtf8(Dest: PChar; Source: PWideChar; MaxBytes: Integer): Integer; overload; deprecated;
    function Utf8ToUnicode(Dest: PWideChar; Source: PChar; MaxChars: Integer): Integer; overload; deprecated;

    function UnicodeToUtf8(Dest: PChar; MaxDestBytes: Cardinal; Source: PWideChar; SourceChars: Cardinal): Cardinal; overload;
    function Utf8ToUnicode(Dest: PWideChar; MaxDestChars: Cardinal; Source: PChar; SourceBytes: Cardinal): Cardinal; overload;
    function UTF8Encode(const WS: WideString): UTF8String;
    function UTF8Decode(const S: UTF8String): WideString;

    function AnsiToUtf8(const S: string): UTF8String;
    function Utf8ToAnsi(const S: UTF8String): string;

  • 相关阅读:
    在单机Hadoop上面增加Slave
    两台机器添加信任关系
    JS Scoping and Hoisting
    SCSS(SASS、CSS)学习
    程序的内存情况
    delete-node-in-a-bst
    serialize-and-deserialize-bst
    Linux Shell脚本编程--curl命令详解
    iOS文件保存策略
    浅谈spring——spring MVC(十一)
  • 原文地址:https://www.cnblogs.com/kmhr/p/8443967.html
Copyright © 2011-2022 走看看