Figuring out what type of text is on the clipboard, and ascii filtering

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Figuring out what type of text is on the clipboard, and ascii filtering

Dr. Hawkins
I'm trying to figure out how to filter potentially unknown source pasted
text into plain 7 bit ASCII.

Working on a mac, for example, the incoming text might be:

   - Honest ASCII
   - Apple 8 bit extended characters
   - MS characters from a Word document created on MS
   - Who knows what coming from a virtual machine
   - HTML clipped from a browser
   - "moronized" text pasted from MS word to a website, then clipped by a
   user
   - who knows what else?


I know I need to intercept paste, but I need to reliably take out any of
the above that SQLite doesn't like.  Fortunately, there is no prospect of
dealing with other than English, or out of ASCII set characters--but they
might come in anyway, such as curly quotes, or something from another
character set.

How can I inspect what is there to figure out how to filter it?

And, in a similar vein, I need to protect agains who-knows-what that the
host OS allows to be entered at the keyboard . . .

--
Dr. Richard E. Hawkins, Esq.
(702) 508-8462
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Figuring out what type of text is on the clipboard, and ascii filtering

dunbarxx
Hi.

I am not sure this is what you need, but might you check the charToNum of each char, and if it is not within a certain range (max 255?) delete it? Doing this with a "repeat for each..." would be quick.

Craig
Reply | Threaded
Open this post in threaded view
|

Re: Figuring out what type of text is on the clipboard, and ascii filtering

Stephen Barncard-4
In reply to this post by Dr. Hawkins
Dr Hawkins,

I don't know if you heard about this in another thread, but perhaps this
simple tool I created will help with at least what's coming into your
clipboard(s).
As you can see, there's a whole lot of other stuff that comes in on the RAW
clipboard data array. I'd never seen these before I added the RAW...

go URL "http://fulton.barncard.com/downloads/livecode/clipboardTest.livecode
"


(Richard - I have the cert attached to the location above but not decided
if that is the final resting place...)
sqb


On Fri, Oct 28, 2016 at 10:48 AM, Dr. Hawkins <[hidden email]> wrote:

> I'm trying to figure out how to filter potentially unknown source pasted
> text into plain 7 bit ASCII.
>
> Working on a mac, for example, the incoming text might be:
>
>    - Honest ASCII
>    - Apple 8 bit extended characters
>    - MS characters from a Word document created on MS
>    - Who knows what coming from a virtual machine
>    - HTML clipped from a browser
>    - "moronized" text pasted from MS word to a website, then clipped by a
>    user
>    - who knows what else?
>



Stephen Barncard - Sebastopol Ca. USA -
mixstream.org
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Figuring out what type of text is on the clipboard, and ascii filtering

Stephen Barncard-4
On Fri, Oct 28, 2016 at 11:17 AM, stephen barncard <
[hidden email]> wrote:

>    - "moronized" text pasted from MS word to a website, then clipped by a
>    user
>    - who knows what else?
>

one could use the knowledge gained from the two arrays (and their keys) and
derive a decision tree on what translation/conversion to perform.

Stephen Barncard - Sebastopol Ca. USA -
mixstream.org
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode