2

I have a challenge to replace English content which comes from AutoCAD annotation to Arabic characters, Arabic fonts for AutoCAD like xarab store Arabic content as English, I just need to replace English content to Arabic by Field Calculator on QGIS.

EXAMPLE: English Content from AutoCAD: lk'rm s:kdm Should display on the screen to: منطقة سكنية

4
  • 2
    Isnt this some encoding issue? Have you tried Layer Properties - Encoding and change to utf-8, or whatever is used in AutoCAD?
    – BERA
    Dec 30, 2021 at 9:48
  • It's a specific autocad font for Arabic language like xarb font, the text appears on the screen as an Arabic but in properties of the text layer, content type is English
    – GIS Man
    Dec 30, 2021 at 11:16
  • I just need a regex to match English keyboard to Arabic keyboard
    – GIS Man
    Dec 30, 2021 at 11:17
  • The concept is match English keyboard to Arabic keyboard
    – GIS Man
    Dec 30, 2021 at 11:18

1 Answer 1

2

The use field calculator, first define a key:value map with matching values for latic/arabic characters. Something like this (here demonstrated with cyrillic characters, as I don't know arabic ones):

map('a','а','b','б','d','д')

meaning:
a -> а
b -> б
d -> д

Then you can create an array of all the characters of your input strings and for each look up the corresponding value to this key character. As we use an array, we have to convert it back to a string and remove the separating commas.

So the whole expression looks like what follows, where line 6 contains the map that you should adapt. text in lines 4 and 7 is the input string.

As an option, you can define lines 5 and 6 (the key:value map with matching characters) as a project variable, let's call it translit and then replace lines 5/6 in the following expression with eval(@translit) (see second screenshot).

replace (
    array_to_string (
        array_foreach (
            generate_series (1,length(text)),
            map_get( 
                map('a','а','b','б','d','д','e','е','g','г','ž','ж','v','в','z','з','i','и','j','й','p','п','P','П','r','р','s','с','o','о','L','Л','n','н','B','Б','R','Р','m','м','M','М'),
                substr( text, @element,1)
            )
        )
    ),
    ',',
    ''
)

enter image description here

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.