Главная страница
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.028 c
15-1187362611
oldman
2007-08-17 18:56
2007.09.16
Гороскопы...


15-1187266184
Nic
2007-08-16 16:09
2007.09.16
2 версии PHP на 1 сервер


15-1184229560
evvcom
2007-07-12 12:39
2007.09.16
FMP (Феодосия Мастак Пати)


15-1187269943
Ega23
2007-08-16 17:12
2007.09.16
О корректном разрыве соединения с сервером БД


15-1187378684
Kostafey
2007-08-17 23:24
2007.09.16
Про запуск cmd