How to get a text from a file online and put it into a field

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

How to get a text from a file online and put it into a field

Post by Mag » Sat Sep 28, 2013 3:21 pm

I'm trying this

Code: Select all

put url "http://www.siteName.com/example.txt" into pageContent
set the unicodeText of field "myText" to uniEncode (pageContent, "UTF8")
Unfortunately in the text is missed every accented character, for example "perché" becomes "perch"... any advice?

PS
If I use

Code: Select all

set the htmlText of field "myText" to pageContent
or

Code: Select all

put pageContent into field "myText"
the accented letters are replaced by incorrect characters

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: How to get a text from a file online and put it into a f

Post by Simon » Sat Sep 28, 2013 10:01 pm

hmmm...
I just tried:

Code: Select all

set the text of fld 1 to url "http://philmrev.on-rev.com/german_french.txt"
All the accents were retained.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: How to get a text from a file online and put it into a f

Post by Mag » Sun Sep 29, 2013 12:35 am

Hi Simon, tested here and doesn't work, I tested also with a new field...
Attachments
Screen Shot 2013-09-29 at 01.31.05.png

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: How to get a text from a file online and put it into a f

Post by Simon » Sun Sep 29, 2013 12:47 am

I think maybe you should tell me a bit more about your app and your setup.
Is that a mobile screen grab? (i think it's a Mac actually).

Maybe this can be handled with ISOToMac?

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: How to get a text from a file online and put it into a f

Post by Mag » Sun Sep 29, 2013 1:03 am

I Simon I'm creating an app for iOS and Android that has as feature also to get text from a XML file. I'm working on a Mac with Mountain Lion. For the tex I just create a new main stack with a button and a scrolling field and put in the button this code:

Code: Select all

set the text of fld 1 to url "http://philmrev.on-rev.com/german_french.txt"
This is the content of the field afther pressing the button
Jemand musste Josef K. verleumdet haben, denn ohne dass er etwas Bˆses getan h‰tte, wurde er eines Morgens verhaftet. ªWie ein Hund!´ sagte er, es war, als sollte die Scham ihn ¸berleben. Als Gregor Samsa eines Morgens aus unruhigen Tr‰umen erwachte, fand er sich in seinem Bett zu einem ungeheueren Ungeziefer verwandelt. Und es war ihnen wie eine Best‰tigung ihrer neuen Tr‰ume und guten Absichten, als am Ziele ihrer Fahrt die Tochter als erste sich erhob und ihren jungen Kˆrper dehnte. ªEs ist ein eigent¸mlicher Apparat´, sagte der Offizier zu dem Forschungsreisenden und ¸berblickte mit einem gewissermaflen bewundernden Blick den ihm doch wohlbekannten Apparat. Sie h‰tten noch ins Boot springen kˆnnen, aber der Reisende hob ein schweres, geknotetes Tau vom Boden, drohte ihnen damit und hielt sie dadurch von dem Sprunge ab. In den letzten Jahrzehnten ist das Interesse an Hungerk¸nstlern sehr zur¸ckgegangen. Aber sie ¸berwanden sich, umdr‰ngten den K‰fig und wollten sich gar nicht fortr¸hren.Jemand musste Josef K. verleumdet haben, denn ohne dass er etwas Bˆses getan h‰tte, wurde er eines Morgens verhaftet. ªWie ein Hund!´ sagte er, es war, als sollte die Scham ihn ¸berleben. Als Gregor Samsa eines Morgens aus unruhigen Tr‰umen erwachte, fand er sich

En se rÈveillant un matin aprËs des rÍves agitÈs, Gregor Samsa se retrouva, dans son lit, mÈtamorphosÈ en un monstrueux insecte. Il Ètait sur le dos, un dos aussi dur quíune carapace, et, en relevant un peu la tÍte, il vit, bombÈ, brun, cloisonnÈ par des arceaux plus rigides, son abdomen sur le haut duquel la couverture, prÍte ‡ glisser tout ‡ fait, ne tenait plus quí‡ peine. Ses nombreuses pattes, lamentablement grÍles par comparaison avec la corpulence quíil avait par ailleurs, grouillaient dÈsespÈrÈment sous ses yeux.´ Quíest-ce qui míest arrivÈ ? ª pensa-t-il. Ce níÈtait pas un rÍve. Sa chambre, une vraie chambre humaine, juste un peu trop petite, Ètait l‡ tranquille entre les quatre murs quíil connaissait bien. Au-dessus de la table o˘ Ètait dÈballÈe une collection díÈchantillons de tissus - Samsa Ètait reprÈsentant de commerce - on voyait accrochÈe líimage quíil avait rÈcemment dÈcoupÈe dans un magazine et mise dans un joli cadre dorÈ. Elle reprÈsentait une dame munie díune toque et díun boa tous les deux en fourrure et qui, assise bien droite, tendait vers le spectateur un lourd manchon de fourrure o˘ tout son avant-bras avait disparu. Le regard de Gregor se tourna ensuite vers
Thanks for the help

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: How to get a text from a file online and put it into a f

Post by Simon » Sun Sep 29, 2013 1:21 am

Yeah it's isoToMac to see it on your Mac.

Code: Select all

put url "http://philmrev.on-rev.com/german_french.txt" into tText
put isoToMac(tText) into fld 1
I just tested on Android and just
set the text of fld 1 to url "http://philmrev.on-rev.com/german_french.txt"
is working

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: How to get a text from a file online and put it into a f

Post by Mag » Sun Sep 29, 2013 1:58 am

Hi Simon, it works great! Thank you! :D

Post Reply