File: hex2utf.mpt

package info (click to toggle)
fis-gtm 7.0-005-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 32,264 kB
  • sloc: ansic: 336,687; asm: 5,184; csh: 4,823; sh: 1,945; awk: 291; makefile: 72; sed: 13
file content (43 lines) | stat: -rwxr-xr-x 1,227 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;								;
;	Copyright 2006 Fidelity Information Services, Inc	;
;								;
;	This source code contains the intellectual property	;
;	of its copyright holder(s), and is made available	;
;	under a license.  If you do not know the terms of	;
;	the license, please stop and do not read further.	;
;								;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
%HEX2UTF;GT.M %HEX2UTF utility - hexadecimal byte stream to UTF-8 string
	;invoke with %U storing the hexadecimal byte stream to return %S having the converted string
	;invoke at INT to execute interactively
	;invoke at FUNC as an extrinsic function
	;

	set %S=$$FUNC(%U)
	quit

INT	new %U
	read !,"Hexadecimal byte stream: ",%U set %S=$$FUNC(%U)
	quit

FUNC(u)
	new l
	set l=$ZLENGTH(u)
	quit $$recurse(1,l)

recurse(start,end);
	new l,m
	set l=end-start+1
	if (l<512) quit $$eval(start,end)
	set m=l\2
	if (m#2=1) set m=m+1
	quit $$recurse(start,start+m-1)_$$recurse(start+m,end)

eval(start,end);
	new i,s,d,s1
	set s1="$zchar("
	for i=start:2:end-2 set s=$zextract(u,i,i+1),d=$$FUNC^%HD(s),s1=s1_d_","
	set i=end-1,s=$zextract(u,i,i+1),d=$$FUNC^%HD(s),s1=s1_d
	set s1=s1_")"
	quit @s1