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
-
ittzy
- Posts: 27
- Joined: Thu Feb 04, 2016 11:48 pm
Post
by ittzy » Wed Apr 20, 2016 10:38 pm
Hi im trying to use unidecode for Scandinavian letters, im trying to put it on a label of an button but i cant get it to work.
It works perfekt with field, here is the code fo my field:
Code: Select all
put uniDecode (the unicodetext of field "h_namn" of stack "fotboll_installningar", "UTF8") after xml
I tried to just change word fld to btn but i guess that is totally wrong..

Here is what im talking about, in my buttons you can see the letters but in my template they dont show. But if i but those names in a field they will show
.igor
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10305
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Wed Apr 20, 2016 11:54 pm
Hi.
Buttons are containers, just like fields. Your handler likely works fine, but you are not seeing what is really happening. Try this. Make a button on a new card. In the message box:
put "5" into btn 1
add 1 to btn 1
answer btn 1
Now where is that "6"? It is in button 1 just as if it was in a field. But you do not see it, because buttons don't work exactly like fields do. What you really want is to deal with the label of that button. Different property:
Code: Select all
put uniDecode (the unicodetext of the label of btn "yourButton" of stack "fotboll_installningar", "UTF8") after xml
Craig Newman
-
ittzy
- Posts: 27
- Joined: Thu Feb 04, 2016 11:48 pm
Post
by ittzy » Thu Apr 21, 2016 8:20 am
hi craig, thx for you help.
I didn't get that first part to try to put 5 in a button?
I tried that string you wrote but i get an error when im trying to press my button
button "h_byte": execution error at line 38 (Chunk: error in object expression) near "3 Henrik Ädehl", char 41
-
jacque
- VIP Livecode Opensource Backer

- Posts: 7389
- Joined: Sat Apr 08, 2006 8:31 pm
-
Contact:
Post
by jacque » Thu Apr 21, 2016 3:37 pm
If you are using LC 7 you don't need to use unidecode. LC 7 automatically works with any character set. Just set the label to the Scandinavian string normally, just as though it were Roman text. The same is true for the XML template.
The only time you need to manage unicode translation is when you are exporting or importing text outside of LC. In those situations use textEncode and textDecode.
All the older unicode text properties are deprecated now. They are still available for legacy stacks but are not necessary for new work.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10305
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Thu Apr 21, 2016 3:45 pm
What happens if you place this into a button script:
Code: Select all
put "5" into btn me
add 1 to me
answer me
You do not see the 5 or the 6, because the contents of a button are not visible. But they are there, since the button is a valid container.
So buttons have labels, which are visible. They may contain data, which is invisible. Fields have labels, but they are invisible. Then may contain data, which is visible.
Craig
-
ittzy
- Posts: 27
- Joined: Thu Feb 04, 2016 11:48 pm
Post
by ittzy » Thu Apr 21, 2016 8:20 pm
I understand that, im using the label in other functions. But now when im trying to show the label of the button in my template it does not show the Scandinavian letters or other not roman letters.
I use LC7, in LC it shows the letters but its when im sending the data to a template it gets wrong.
-
jacque
- VIP Livecode Opensource Backer

- Posts: 7389
- Joined: Sat Apr 08, 2006 8:31 pm
-
Contact:
Post
by jacque » Thu Apr 21, 2016 8:30 pm
ittzy wrote:I use LC7, in LC it shows the letters but its when im sending the data to a template it gets wrong.
If your template is another file on disk, you need to use textEncode before writing it to the file:
Code: Select all
put textEncode(field "h_namn" of stack "fotboll_installningar", "UTF8") after xml
When you read the xml file back into LiveCode, decode it:
Code: Select all
put textDecode(tTemplateText,"UTF8") into xml
These two functions replace the old uniEncode and uniDecode functions. You only need to use them when importing or exporting text to a non-LiveCode destination.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
-
ittzy
- Posts: 27
- Joined: Thu Feb 04, 2016 11:48 pm
Post
by ittzy » Thu Apr 21, 2016 8:44 pm
Here is the part of that code that gets a error.
Code: Select all
put "<componentData id=\" after xml
put quote after xml
// Flashbox
put "h_spelare1\" after xml
put quote after xml
put "><data id=\" after xml
put quote after xml
put "text\" after xml
put quote after xml
put " value=\" after xml
put quote after xml
//Field Livecode
put uniDecode (the unicodetext of the label of btn "h_in", "UTF8") after xml
put "\" after xml
put quote after xml
-
jacque
- VIP Livecode Opensource Backer

- Posts: 7389
- Joined: Sat Apr 08, 2006 8:31 pm
-
Contact:
Post
by jacque » Thu Apr 21, 2016 9:17 pm
What do you do with the xml text? Do you use it only in LiveCode? Are you writing the xml to a file? The script shouldn't use uniDecode when creating the xml:
Code: Select all
put "<componentData id=\" after xml
put quote after xml
// Flashbox
put "h_spelare1\" after xml
put quote after xml
put "><data id=\" after xml
put quote after xml
put "text\" after xml
put quote after xml
put " value=\" after xml
put quote after xml
//Field Livecode
put the label of btn "h_in" after xml -- use this text normally
put "\" after xml
put quote after xml
If you save the xml to a text file on disk, use the textEncode function before writing the file and use textDecode when reading the file. If you are saving the template in the stack, you don't need to do anything special with the text, it is already in the correct format for LiveCode.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
-
ittzy
- Posts: 27
- Joined: Thu Feb 04, 2016 11:48 pm
Post
by ittzy » Thu Apr 21, 2016 9:55 pm
hi im not writing a xml thats just instead of myvariable (just a text) when i was learning livecode a guy showed my a bit of code and i kept useing that "xml".
As i wrote, im sending this text to a flash template.
When i use it like you told me "put the label of btn" my letters as å,ä,ö does not show but everything els show so fot example if i write "Igår" it shows "Igr" in the template. But i LC i see all the letters
usually i would write this if it was a fld and it works perfekt... put uniDecode (the unicodetext of field "name of fld", "UTF8") after myVariable
Now i need to get it to work with btn label
-
ittzy
- Posts: 27
- Joined: Thu Feb 04, 2016 11:48 pm
Post
by ittzy » Sun Apr 24, 2016 3:27 pm
Unicodelabel