Skip to main content

Replace control character

  • October 2, 2019
  • 7 replies
  • 1 view

Knut Dybendahl
Forum|alt.badge.img

Hi all,

Short of writing a 3gl function to do this.....

I'm processing a number of txt files - and every now and then I come across a control character

which causes good ol' Uniface to have a hissy fit.

The control character in question is HEX 0x1a - Ascii 26. 

I've tried a $replace in combination with $tometa (result in a $2) - no joy..

Any other ideas out there?


Knut

7 replies

Iain Sharp
Forum|alt.badge.img+5
  • Inspiring
  • October 2, 2019

Hi all,

Short of writing a 3gl function to do this.....

I'm processing a number of txt files - and every now and then I come across a control character

which causes good ol' Uniface to have a hissy fit.

The control character in question is HEX 0x1a - Ascii 26. 

I've tried a $replace in combination with $tometa (result in a $2) - no joy..

Any other ideas out there?


Knut

Out of curiosity, what kind of hissy fit? 


Knut Dybendahl
Forum|alt.badge.img
  • Author
  • Participating Frequently
  • October 2, 2019

Hi all,

Short of writing a 3gl function to do this.....

I'm processing a number of txt files - and every now and then I come across a control character

which causes good ol' Uniface to have a hissy fit.

The control character in question is HEX 0x1a - Ascii 26. 

I've tried a $replace in combination with $tometa (result in a $2) - no joy..

Any other ideas out there?


Knut

processing a list created from comma separated line items ==> internal UF infinite loop - 100% cpu usage.


Michael Taylor

Hi all,

Short of writing a 3gl function to do this.....

I'm processing a number of txt files - and every now and then I come across a control character

which causes good ol' Uniface to have a hissy fit.

The control character in question is HEX 0x1a - Ascii 26. 

I've tried a $replace in combination with $tometa (result in a $2) - no joy..

Any other ideas out there?


Knut

Hi Knut,

Have you tried the $string function? https://u.uniface.info/docs/1000/uniface/proc/reference/ProcFunctions/_string.htm#microcontent1


Norbert Lauterbach
Forum|alt.badge.img+3

Hi all,

Short of writing a 3gl function to do this.....

I'm processing a number of txt files - and every now and then I come across a control character

which causes good ol' Uniface to have a hissy fit.

The control character in question is HEX 0x1a - Ascii 26. 

I've tried a $replace in combination with $tometa (result in a $2) - no joy..

Any other ideas out there?


Knut

Are there much more undocumented Features in Uniface like $tometa???

Can't find anything in Uniface Documentation about $tometa!!!


Take a sample program:

numeric dis(9999) n


variables
 string c, e, s, z, r
endvariables
r = "-X-"
for $n$ = 0 to 255
 z = "&#%%$n$%%%;"
 c = $string(z)
 s = $concat("A...", c, "...Z")
 s = $replace(s, 1, c, r, -1)
 putmess "%%z : %%s"
endfor


 : A......Z

 : A...-X-...Z

 : A......Z


$replace will replace all characters but  and 

That's not really nice UNIFACE!

Please STOP this!!!


Norbert


Michael Taylor

Hi all,

Short of writing a 3gl function to do this.....

I'm processing a number of txt files - and every now and then I come across a control character

which causes good ol' Uniface to have a hissy fit.

The control character in question is HEX 0x1a - Ascii 26. 

I've tried a $replace in combination with $tometa (result in a $2) - no joy..

Any other ideas out there?


Knut

Changing the snippet to encode the string as URAW also gives the correct result for characters   

trigger detail
	variables
		string e, s, z, r
		raw c 
	endvariables

	r = "-X-"
	for $n$ = 0 to 255
		z = "&#%%$n$%%%;"
		c = $encode("URAW", $string(z))
		s = $concat("A...", c, "...Z")
		s = $replace(s, 1, c, r, -1)
		putmess "%%z : %%s"
	endfor
end

Forum|alt.badge.img
  • Participating Frequently
  • October 3, 2019

Hi all,

Short of writing a 3gl function to do this.....

I'm processing a number of txt files - and every now and then I come across a control character

which causes good ol' Uniface to have a hissy fit.

The control character in question is HEX 0x1a - Ascii 26. 

I've tried a $replace in combination with $tometa (result in a $2) - no joy..

Any other ideas out there?


Knut

Hi all,

Nasty solution, but do you try to input the character "26" directly in $replace.

like $replace(buffer,1,"→" ,"",-1)

→ : alt+numpad 26.




Knut Dybendahl
Forum|alt.badge.img
  • Author
  • Participating Frequently
  • October 6, 2019

Changing the snippet to encode the string as URAW also gives the correct result for characters   

trigger detail
	variables
		string e, s, z, r
		raw c 
	endvariables

	r = "-X-"
	for $n$ = 0 to 255
		z = "&#%%$n$%%%;"
		c = $encode("URAW", $string(z))
		s = $concat("A...", c, "...Z")
		s = $replace(s, 1, c, r, -1)
		putmess "%%z : %%s"
	endfor
end

Hi Mike,

This threw me for a loop for quite some time...

Until - doing a fileload/raw, $replace, filedump/raw which finally fixed the darn control character.

Thanking you!