From 1f713f706e9e87fe9dd35b38d035f3a5bb511527 Mon Sep 17 00:00:00 2001 From: Massimo Melina Date: Thu, 11 Jun 2020 11:40:12 +0200 Subject: [PATCH] {.convert|utf-8|dec/hex.} --- scriptLib.pas | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/scriptLib.pas b/scriptLib.pas index 90c2f78..cee3ebb 100644 --- a/scriptLib.pas +++ b/scriptLib.pas @@ -665,11 +665,30 @@ var end; // inc_ procedure convert(); + var + dst, s: string; + c: ansichar; begin - if sameText(p, 'ansi') and sameText(par(1), 'utf-8') then - result:=string(ansiToUTF8(ansistring(par(2)))) - else if sameText(p, 'utf-8') and sameText(par(1), 'ansi') then - result:=utf8ToAnsi(ansistring(par(2))) + dst:=par(1); + s:=par(2); + if sameText(p, 'ansi') and sameText(dst, 'utf-8') then + result:=string(ansiToUTF8(ansistring(s))) + else if sameText(p, 'utf-8') then + if sameText(dst, 'ansi') then + result:=utf8ToAnsi(ansistring(s)) + else if dst='dec' then + begin + result:=''; + for c in UTF8encode(s) do + result:=result+intToStr(ord(c))+','; + setLength(result, length(result)-1); + end + else if dst='hex' then + begin + result:=''; + for c in UTF8encode(s) do + result:=result+intToHex(ord(c)); + end end; // convert procedure encodeuri(); @@ -1913,9 +1932,15 @@ try disconnect(); if name = 'stop server' then +- begin stopServer(); + exit(''); + end; if name = 'start server' then + begin startServer(); + exit(''); + end; if name = 'focus' then