Код: Выделить всё
{ MSEgui Copyright (c) 2007 by IvankoB
See the file COPYING.MSE, included in this distribution,
for details about the copyright.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
}
unit mseru2ucs2;
{$ifdef FPC}{$mode objfpc}{$h+}{$endif}
interface
uses
msestrings;
function c866toucs2(const avalue: char): widechar;
function c866toucs2(const avalue: ansistring): widestring;
implementation
const
cp_ucs2_1: array [$b0..$df] of cardinal = (
$2591,$2592,$2593,$2502,$2524,$2561,$2562,$2556,$2555,$2563,$2551,
$2557,$255d,$255c,$255b,$2510,$2514,$2534,$252c,$251c,$2500,$253c,
$255e,$255f,$255a,$2554,$2569,$2566,$2560,$2550,$256c,$2567,$2568,
$2564,$2565,$2559,$2558,$2552,$2553,$256b,$256a,$2518,$250c,$2588,
$2584,$258c,$2590,$2580
);
cp_ucs2_2: array [$f0..$ff] of cardinal = (
$401,$451,$404,$454,$407,$457,$40e,$45e,$ba,$2219,$b7,$221a,$2116,
$a4,$25a0,$a0
);
function c866toucs2(const avalue: char): widechar;
var
i: byte;
begin
i:= byte(avalue);
case i of
$0..$7f: result:= widechar(avalue);
$80..$af: result:= widechar(i+$390);
$b0..$df: result:= widechar(cp_ucs2_1[i]);
$e0..$ef: result:= widechar(i+$360);
$f0..$ff: result:= widechar(cp_ucs2_2[i]);
else
result:= widechar($20);
end;
end;
function c866toucs2(const avalue: ansistring): widestring;
var
i,i1: integer;
begin
i1:= length(avalue);
setlength(result,i1);
for i:= 1 to i1 do begin
result[i]:= widechar(c866toucs2(avalue[i]));
end;
end;
end.
и рабочий пример приаттачен.
Перекодировка сделана прямо в в датасете.