Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2007.09.16;
Скачать: CL | DM;

Вниз

UTF   Найти похожие ветки 

 
del-l-lphi   (2007-08-18 13:01) [0]

Может кто-то сталкивался с такой ситуацией. У меня в переменной типа widestring текст, как проверить является ли текст UTF, если да, то какой от UTF8 или UTF16?


 
wl ©   (2007-08-18 13:04) [1]

utf16 это и есть реальный юникод. а чтобы узнать, что это utf8, то слишком мало данных - для русских букв можно узнать по сигнатурам старшегог байта, для иероглифов - нет (имхо)


 
del-l-lphi   (2007-08-18 21:12) [2]

А как тогда вообще имея данные в UTF8 привести их к формату юникода?


 
palva ©   (2007-08-18 21:30) [3]

Цитата из C:\Program Files\Borland\BDS\4.0\source\Win32\rtl\sys\System.pas

{ PChar/PWideChar Unicode <-> UTF8 conversion }

// UnicodeToUTF8(3):
// UTF8ToUnicode(3):
// Scans the source data to find the null terminator, up to MaxBytes
// Dest must have MaxBytes available in Dest.
// MaxDestBytes includes the null terminator (last char in the buffer will be set to null)
// Function result includes the null terminator.

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

// UnicodeToUtf8(4):
// UTF8ToUnicode(4):
// MaxDestBytes includes the null terminator (last char in the buffer will be set to null)
// Function result includes the null terminator.
// Nulls in the source data are not considered terminators - SourceChars must be accurate

function UnicodeToUtf8(Dest: PChar; MaxDestBytes: Cardinal; Source: PWideChar; SourceChars: Cardinal): Cardinal; overload;
function Utf8ToUnicode(Dest: PWideChar; MaxDestChars: Cardinal; Source: PChar; SourceBytes: Cardinal): Cardinal; overload;

{ WideString <-> UTF8 conversion }

function UTF8Encode(const WS: WideString): UTF8String;
function UTF8Decode(const S: UTF8String): WideString;

{ Ansi <-> UTF8 conversion }

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



 
Anatoly Podgoretsky ©   (2007-08-18 22:16) [4]

> del-l-lphi  (18.08.2007 21:12:02)  [2]

MultiByteToWideChar



Страницы: 1 вся ветка

Текущий архив: 2007.09.16;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.018 c
2-1187861807
tim_ka
2007-08-23 13:36
2007.09.16
Label на TImage


2-1187875140
Fleg
2007-08-23 17:19
2007.09.16
проблема со свойствами объекта


15-1187722658
matt
2007-08-21 22:57
2007.09.16
Книжку ищу.


15-1187771820
Jeer
2007-08-22 12:37
2007.09.16
Библиотека DC


2-1187927020
Gydvin
2007-08-24 07:43
2007.09.16
Чтение wmf