How can i convert popupmenu choosing result… as text to a textEncoding function
s = TextField1.Text.ConvertEncoding(Encodings.(Popupmenu result))
Beside use Select Case… For each encoding possibility
Each way that i’ve tried result to type mismatch error
Put your code in PopupMenu1.Change, using the (PopupMenu) displayed encoding ?
I’m not sure to understand… Or my question is not clear enough
I want to apply the result of the selection… which is the text encoding possibility TO another text
So i want to convert text selection…to a convert function to apply
Yes my code is in Change event… but
s = TextField1.Text.ConvertEncoding(Encodings.(Popupmenu result.text))
return error of type mismatch… that i understand… because it’s a text and xojo want the encoding object
I do not recall exactly how i’ve done it; maybe I used:
[code]Select Case PopupMenu1.Text
// Apply here the UTF8 encoding to the selected text
// and so on
After all, above is just some lines of code (unless you absolutely have to use a specific encoding, this millenium default encoding is UTF-8 (IMHO).
I cannot run Xojo right now (all memory used by multiple applications).
But i mentioned [quote]Beside use Select Case… For each encoding possibility[/quote]
I search for a shortcut to assign automatically the chosen encoding
@Denis Despres You cannot use directly the name from your popup. However, you may use the internetName and use it to retrieve the corresponding encoding with:
Function FindEncoding( withName as String ) as TextEncoding
for i as integer=0 to Encodings.Count - 1
if Encodings.Item( i ).internetName=withName then
return Encodings.Item( i )
The popupmenu has rows.
Each row has a rowtag
A rowtag is a variant
If you addrow with the NAME of the encoding, then set the popup.rowtag(popup.lastindex) =
You may be able to get the ROWTAG back from the popup, and use that directly.
Thanks it work… partially
The list of Encodings.Item( i ).internetName didn’t contain all encoding ( or the name’s doesn’t match )
specially the one that i need… DosLatin1
@Denis Despres Well it does contain it, but not with this name. Look at Encodings.DosLatin1.InternetName to see its internet name (well, according to Xojo)
Nahhh not very convenient !
Convert from popupmenu.text TO ( find matching internetName )… then convert i to TextEncoding
The Select Case listing is faster to code
If you populated the popup with:
for i as integer = 0 to Encodings.Count-1
Then you can get the correct encoding chosen in popup with
By the way, DOSLatin1 is cp850