/ Development  

Play with diacritics in a textfield

Hi there AppWorks fans,

Welcome to a new installment of AppWorks tips.

This time we’ll cover the thing we call ‘Diacritics’. If you never heard of it (like I did in the past) you can read some Wiki information here. They are characters with an ‘add-on’, and we know (from previous knowledge) they can be a struggle when you want to use them in a solution. So, it’s good to know if they can be used in AppWorks and how they are saved in the database. And we’ll a little bit from the database again…because we can!

Let get right into it…

Let’s spin up our machine and find out what entity we can use for this check. Looks like we use the ‘Category’ as we have a cat_name of type ‘Text’ with max. length of 64.


They are already published so we should be able to create new instances in the front-end. Just create some and then we’ll investigate the database with HeidiSQL.

This should be your database connection information to our PostgreSQL database (password ‘admin’ in my case)


And execute a simple query like this SELECT id, cat_name, cat_description from o2appworkstipsappworkscategory

With a result like this


Now change the name of the category (in the ‘/app/start’ front-end) and make it something like this (just copy/paste the text) diakrī́nō…8 characters…right?

Or is it 9 as my beloved notepad++ tells me once I select the text!?


Or is it length 12 like the other red arrow shows us!?

And what will happen when we reach the max. length 64 of my cat_name property!?


Let try it out by just changing the cat_name value in the front-end, let the auto-save do the work and check the database…Looks fine to me…great!


OK…now fill the field till max. length is reached: diakrī́nōdiakrī́nōdiakrī́nōdiakrī́nōdiakrī́nōdiakrī́nōdiakrī́nōd

Fine…we have a match…great again!


But how long is this string when you just count the ‘real’ characters…57 chars…agree? and that does not match the max. length of 64!

But what is notepad++ telling us about this string?


What is happening here?

That is the ‘magic’ of diacritics where 1 character will use more ‘space/length’ and more specific…It uses an extra ‘space’ for each ‘add-on’ to the char. For our test string you can keep this in mind:

  • diakr use per char is 1 space, so that is a space length of 5
  • ī́ looks like 1 char with 1 space but is 2 charters ( ī + ́ ) where the first one uses 2 space and the second 1 space?…No, that one also uses 2 spaces. So, that is a space length of 2 + 2 = 4 for that 1 diacritical character!!
  • n is 1 char with 1 space length
  • ō is 1 char with 2 space length

And that makes 5 + 4 + 1 + 2 = 12 space length!

There is even more to talk about, but that is more about the collation (e.g. UTF-8) settings on database level, not for now, but you could search the internet on that one in combination with diacritics.

For PostgreSQL you can find the collation for your database with this query: select datname, datcollate from pg_database;


And this gives us a simple ‘DONE’ on using diacritics in AppWorks. With 1 big lesson learned that 1 diacritic character might use more than 1 space length in your database! Something to remember in the future when you add a maximum length to your text field. Have a good one for today and I see you in the next post about a new AppWorks installment…Cheers.

Don’t forget to subscribe to get updates on the activities happening on this site.