Adding unicode symbols in sqlite db

  1. 4 months ago
    Edited 4 months ago

    I have an app where I display unicode symbols. I’m using a dictionary which works well.

    d.Value(&u00FC) = “&u00FC”
    d.Value(&u06DE) = "&u06DE”

    I add the value and key in a listbox and this will show the unicode and the symbol

    -image-

    I want to use a sqlite db to contain both the unicode and symbol so I created a db and copied everything. The database works well with the copied data (as text data type) but my problem is being able to add new unicode and symbols.
    I have a textfield to enter the unicode (example &u1F5DD)
    Setting d.Value is the problem. If I set d.Value(Textfield.text) it won’t convert to a symbol as it would if I entered d.Value(&u1F5DD).
    How can I set d.value so it works the same as a dictionary. I believe d.Value must be something other than text to display the symbol properly.
    Once the unicode and symbol is created in the dictionary I can copy it to the db and the symbol will show properly.
    PS: I’m a self taught hobby programmer.

    writing "&u06DE" in a text field gives you the characters &, u, 0, 6, D, E (6 characters)
    its NOT the same as the single unicode characters &u06DE

    06De is JUST a number - but in unicode the number of a specific character (the number is its code point)
    So you can do something like

    // replace the &u with &h
    dim codePointString as string = replaceall(textfield1.text, "&u", "&h")
    
    // turn the code point string into the number
    Dim codePoint As Integer = val(codePointString)
    
    // now get the character for that code point
    Dim actualChar As String = Encodings.UTF8.Chr( codePoint )

    acnd actualChar will have the character for &u06DE if thats what you typed in

  2. Markus W

    Aug 10 #JeSuisHuman New Zealand, Auc...

    Not sure what you are trying to achieve, but I use a module with constants like

    Module emojis

    With a string constant Snowman and it’s value being ☃️

  3. Markus

    The dictionary is hard coded in the app, so when I want to add a new item I have to open the app in XOJO ide to add the new item. What I want with a db is be able to add new unicodes from the running app.

    Using a textfield to add unicode (example &u06DE added as d.Value(textfield1.text) will not
    show -image- in the db as key, instead key is “&u06DE”.

  4. Norman P

    Aug 10 Pre-Release Testers, Xojo Pro Answer under a bus
    Edited 4 months ago

    writing "&u06DE" in a text field gives you the characters &, u, 0, 6, D, E (6 characters)
    its NOT the same as the single unicode characters &u06DE

    06De is JUST a number - but in unicode the number of a specific character (the number is its code point)
    So you can do something like

    // replace the &u with &h
    dim codePointString as string = replaceall(textfield1.text, "&u", "&h")
    
    // turn the code point string into the number
    Dim codePoint As Integer = val(codePointString)
    
    // now get the character for that code point
    Dim actualChar As String = Encodings.UTF8.Chr( codePoint )

    acnd actualChar will have the character for &u06DE if thats what you typed in

  5. Markus W

    Aug 10 #JeSuisHuman New Zealand, Auc...

    Btw note that not all fonts have implemented all code points!

  6. Norman
    Thank you, that solved my problem. I knew text would not work but I didn't know how to get the correct code.

or Sign Up to reply!