Главная страница
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.017 c
11-1168520708
Psychedelic
2007-01-11 16:05
2007.09.16
Всем: Какие компоненты хотелось бы видеть в KOL?


15-1187370188
EEefe
2007-08-17 21:03
2007.09.16
visual studio 2005 и visual studio .net


15-1187358690
Kerk
2007-08-17 17:51
2007.09.16
Спекулянты и ОМОН


15-1187530512
ArtemESC
2007-08-19 17:35
2007.09.16
Шахматная программа


15-1187506728
rol_intal@mail.ru
2007-08-19 10:58
2007.09.16
сименс сотовый