Главная страница
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.026 c
8-1165916716
zenov
2006-12-12 12:45
2007.09.16
как подключить к своей проге плагины аудиовывода из Winamp?


2-1187515795
RakoT
2007-08-19 13:29
2007.09.16
FileExists


2-1187571706
Abcdef123
2007-08-20 05:01
2007.09.16
Чем можно заменить свойство Enabled?


9-1159867542
codent
2006-10-03 13:25
2007.09.16
Как делать игры


15-1187598333
Наташа
2007-08-20 12:25
2007.09.16
Обращение к мадератором