Undisplayable Character

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Undisplayable Character

Michael Gross-4

Hi,

        Anyone have some simple code to remove an Undisplayable character from a text field?

 

Thanks!


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Undisplayable Character

Michael Gross-4

Hi,

        Anyone have some code to remove an Undisplayable character from a text field?

 

Thanks!

 

Mike

 


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Undisplayable Character

Paul Baumann

The modification below (to the toRead block) was used to prevent double-byte strings from being pasted into ANY text fields of VW:

 

PrintConverter>>initForString

                "Initialize the receiver to convert to and from

                String's print representations."

 

                toPrint :=

                                [:m |

                                                | val |

                                                (val := m ) == nil

                                                                ifTrue: [String new]

                                                                ifFalse: [val]].

                toRead := [:v |

                                | s |

                                s := v string.

                                (s isKindOf: TwoByteString) ifTrue: [s := s asSingleByteString].

                                s

                ]

 

TwoByteString>>asSingleByteString

                | newString |

                newString := Core.String new: self size.

                1 to: self size

                                do:

                                                [:idx |

                                                | char |

                                                char := self at: idx.

                                                char asInteger > 256

                                                                ifTrue: [newString at: idx put: $ ]

                                                                ifFalse: [newString at: idx put: char]].

                ^newString

 

You could do something similar to strip or replace the characters that you do not want. Unfortunately VW doesn't make it easy to customize the converters or define your own; it doesn't even have accessor methods for the individual attributes that are useful to change. Developers are faced with a choice of many nasty hacks or a simple change like this that affects the entire image.

 

Paul Baumann

 

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Michael Gross
Sent: Thursday, August 14, 2014 08:14
To: [hidden email]
Subject: [vwnc] Undisplayable Character

 

Hi,

        Anyone have some code to remove an Undisplayable character from a text field?

 

Thanks!

 

Mike

 



This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of Intercontinental Exchange, Inc. (ICE), its subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired.

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Undisplayable Character

Holger Kleinsorgen
Paul Baumann wrote
The modification below (to the toRead block) was used to prevent double-byte strings from being pasted into ANY text fields of VW:
....
This will also remove all displayable characters beyond code point 255.
Reply | Threaded
Open this post in threaded view
|

Re: Undisplayable Character

Steven Kelly
Holger Kleinsorgen wrote Friday, August 15, 2014 11:08 AM:
> Paul Baumann wrote
> > The modification below (to the toRead block) was used to prevent
> > double-byte strings from being pasted into ANY text fields of VW:
> > ....
>
> This will also remove all displayable characters beyond code point 255.

I don't think it was intended to be a drop-in solution. As Paul said:
"You could do something similar to strip or replace the characters that you
do not want"

In any case, Mike's real problem is the definition of "undisplayable
character". Is that:
a) undisplayable on any machine, with any OS, with any fonts, under any
circumstances, or
b) undisplayable on the current machine in some current font etc., or
c) possibly undisplayable on some machine in the world under some conditions

There are few characters in a), many in c), and a massively varying amount in
b). VW itself doesn't know the answer to the question for all characters,
even in case b) - it just sends the character to the OS to display, and that
may result in white space, nothing, a black rectangle, or a nonsense
character depending on the font. For the cases it does know, see
DisplayScanner>>characterNotInFont.

An easier question is "unsavable character" - if you know the encoding you
use when writing to disk or network, you can see if the character is
supported in that encoding (see UnsupportedCharacterError).

All the best,
Steve

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Undisplayable Character

Reinout Heeck-3
In reply to this post by Paul Baumann

I haven't played with this code, but at first blush it seems to contain an off-by-one error:


                                                char asInteger > 256

                                                                ifTrue: [newString at: idx put: $ ]

                                                                ifFalse: [newString at: idx put: char]].




R
-


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Undisplayable Character

Paul Baumann

Yep. Looks that way to me too. Fortunately I wasn't the one to write that code. :)

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Reinout Heeck
Sent: Monday, August 18, 2014 05:53
To: [hidden email]
Subject: Re: [vwnc] Undisplayable Character

 


I haven't played with this code, but at first blush it seems to contain an off-by-one error:



                                                char asInteger > 256

                                                                ifTrue: [newString at: idx put: $ ]

                                                                ifFalse: [newString at: idx put: char]].

 



R
-



This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of Intercontinental Exchange, Inc. (ICE), its subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired.

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc