DIRCTORY, ShFileOperation and Codepage <-> Keyboard Layout

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

DIRCTORY, ShFileOperation and Codepage <-> Keyboard Layout

Post by AUGE_OHR »

hi,

i try to copy Files with ShfileOperation like Explore

for German OS i have to use

Code: Select all

   SET CODEPAGE TO GERMAN
else i got Error with German "Umlaute" ( > CHR(128) )

---

to "Identify" which OS is used i "test Keyboard" Setting it this Way

Code: Select all

LOCAL nCountry := HB_bitAND( GETKEYBOARDLAYOUT(), 0xFFFF )
IF nCountry = 1031
   SET LANGUAGE TO GERMAN
now i like to know what nCountry does have
ENGLISH | SPANISH | BULGARIAN | *GERMAN | GREEK | HUNGARIAN | POLISH | PORTUGUESE | RUSSIAN | SERBIAN | SLOVENIAN
have fun
Jimmy
edk
Posts: 997
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: DIRCTORY, ShFileOperation and Codepage <-> Keyboard Layout

Post by edk »

Take a look at this list:

Code: Select all

             Locale                 Language code  LCID string      LCID decimal     LCID hex       Codepage
Afrikaans                           af             af                       1078          436           1252
Albanian                            sq             sq                       1052          41C           1250
Amharic                             am             am                       1118          45E
Arabic - Algeria                    ar             ar-dz                    5121         1401           1256
Arabic - Bahrain                    ar             ar-bh                   15361         3C01           1256
Arabic - Egypt                      ar             ar-eg                    3073          C01           1256
Arabic - Iraq                       ar             ar-iq                    2049          801           1256
Arabic - Jordan                     ar             ar-jo                   11265         2C01           1256
Arabic - Kuwait                     ar             ar-kw                   13313         3401           1256
Arabic - Lebanon                    ar             ar-lb                   12289         3001           1256
Arabic - Libya                      ar             ar-ly                    4097         1001           1256
Arabic - Morocco                    ar             ar-ma                    6145         1801           1256
Arabic - Oman                       ar             ar-om                    8193         2001           1256
Arabic - Qatar                      ar             ar-qa                   16385         4001           1256
Arabic - Saudi Arabia               ar             ar-sa                    1025          401           1256
Arabic - Syria                      ar             ar-sy                   10241         2801           1256
Arabic - Tunisia                    ar             ar-tn                    7169         1C01           1256
Arabic - United Arab Emirates       ar             ar-ae                   14337         3801           1256
Arabic - Yemen                      ar             ar-ye                    9217         2401           1256
Armenian                            hy             hy                       1067          42B
Assamese                            as             as                       1101          44D
Azeri - Cyrillic                    az             az-az                    2092          82C           1251
Azeri - Latin                       az             az-az                    1068          42C           1254
Basque                              eu             eu                       1069          42D           1252
Belarusian                          be             be                       1059          423           1251
Bengali - Bangladesh                bn             bn                       2117          845
Bengali - India                     bn             bn                       1093          445
Bosnian                             bs             bs                       5146         141A
Bulgarian                           bg             bg                       1026          402           1251
Burmese                             my             my                       1109          455
Catalan                             ca             ca                       1027          403           1252
Chinese - China                     zh             zh-cn                    2052          804
Chinese - Hong Kong SAR             zh             zh-hk                    3076          C04
Chinese - Macau SAR                 zh             zh-mo                    5124         1404
Chinese - Singapore                 zh             zh-sg                    4100         1004
Chinese - Taiwan                    zh             zh-tw                    1028          404
Croatian                            hr             hr                       1050          41A           1250
Czech                               cs             cs                       1029          405           1250
Danish                              da             da                       1030          406           1252
Dutch - Belgium                     nl             nl-be                    2067          813           1252
Dutch - Netherlands                 nl             nl-nl                    1043          413           1252
Edo                                                                         1126          466
English - Australia                 en             en-au                    3081          C09           1252
English - Belize                    en             en-bz                   10249         2809           1252
English - Canada                    en             en-ca                    4105         1009           1252
English - Caribbean                 en             en-cb                    9225         2409           1252
English - Great Britain             en             en-gb                    2057          809           1252
English - India                     en             en-in                   16393         4009
English - Ireland                   en             en-ie                    6153         1809           1252
English - Jamaica                   en             en-jm                    8201         2009           1252
English - New Zealand               en             en-nz                    5129         1409           1252
English - Philippines               en             en-ph                   13321         3409           1252
English - Southern Africa           en             en-za                    7177         1C09           1252
English - Trinidad                  en             en-tt                   11273         2C09           1252
English - United States             en             en-us                    1033          409           1252
English - Zimbabwe                  en                                     12297         3009           1252
Estonian                            et             et                       1061          425           1257
FYRO Macedonia                      mk             mk                       1071          42F           1251
Faroese                             fo             fo                       1080          438           1252
Farsi - Persian                     fa             fa                       1065          429           1256
Filipino                                                                    1124          464
Finnish                             fi             fi                       1035          40B           1252
French - Belgium                    fr             fr-be                    2060          80C           1252
French - Cameroon                   fr                                     11276         2C0C
French - Canada                     fr             fr-ca                    3084          C0C           1252
French - Congo                      fr                                      9228         240C
French - Cote d'Ivoire              fr                                     12300         300C
French - France                     fr             fr-fr                    1036          40C           1252
French - Luxembourg                 fr             fr-lu                    5132         140C           1252
French - Mali                       fr                                     13324         340C
French - Monaco                     fr                                      6156         180C           1252
French - Morocco                    fr                                     14348         380C
French - Senegal                    fr                                     10252         280C
French - Switzerland                fr             fr-ch                    4108         100C           1252
French - West Indies                fr                                      7180         1C0C
Frisian - Netherlands                                                       1122          462
Gaelic - Ireland                    gd             gd-ie                    2108          83C
Gaelic - Scotland                   gd             gd                       1084          43C
Galician                            gl                                      1110          456           1252
Georgian                            ka                                      1079          437
German - Austria                    de             de-at                    3079          C07           1252
German - Germany                    de             de-de                    1031          407           1252
German - Liechtenstein              de             de-li                    5127         1407           1252
German - Luxembourg                 de             de-lu                    4103         1007           1252
German - Switzerland                de             de-ch                    2055          807           1252
Greek                               el             el                       1032          408           1253
Guarani - Paraguay                  gn             gn                       1140          474
Gujarati                            gu             gu                       1095          447
HID (Human Interface Device)                                                1279          4FF
Hebrew                              he             he                       1037          40D           1255
Hindi                               hi             hi                       1081          439
Hungarian                           hu             hu                       1038          40E           1250
Icelandic                           is             is                       1039          40F           1252
Igbo - Nigeria                                                              1136          470
Indonesian                          id             id                       1057          421           1252
Italian - Italy                     it             it-it                    1040          410           1252
Italian - Switzerland               it             it-ch                    2064          810           1252
Japanese                            ja             ja                       1041          411
Kannada                             kn             kn                       1099          44B
Kashmiri                            ks             ks                       1120          460
Kazakh                              kk             kk                       1087          43F           1251
Khmer                               km             km                       1107          453
Konkani                                                                     1111          457
Korean                              ko             ko                       1042          412
Kyrgyz - Cyrillic                                                           1088          440           1251
Lao                                 lo             lo                       1108          454
Latin                               la             la                       1142          476
Latvian                             lv             lv                       1062          426           1257
Lithuanian                          lt             lt                       1063          427           1257
Malay - Brunei                      ms             ms-bn                    2110          83E           1252
Malay - Malaysia                    ms             ms-my                    1086          43E           1252
Malayalam                           ml             ml                       1100          44C
Maltese                             mt             mt                       1082          43A
Manipuri                                                                    1112          458
Maori                               mi             mi                       1153          481
Marathi                             mr             mr                       1102          44E
Mongolian                           mn             mn                       2128          850
Mongolian                           mn             mn                       1104          450           1251
Nepali                              ne             ne                       1121          461
Norwegian - Bokml                   nb             no-no                    1044          414           1252
Norwegian - Nynorsk                 nn             no-no                    2068          814           1252
Oriya                               or             or                       1096          448
Polish                              pl             pl                       1045          415           1250
Portuguese - Brazil                 pt             pt-br                    1046          416           1252
Portuguese - Portugal               pt             pt-pt                    2070          816           1252
Punjabi                             pa             pa                       1094          446
Raeto-Romance                       rm             rm                       1047          417
Romanian - Moldova                  ro             ro-mo                    2072          818
Romanian - Romania                  ro             ro                       1048          418           1250
Russian                             ru             ru                       1049          419           1251
Russian - Moldova                   ru             ru-mo                    2073          819
Sami Lappish                                                                1083          43B
Sanskrit                            sa             sa                       1103          44F
Serbian - Cyrillic                  sr             sr-sp                    3098          C1A           1251
Serbian - Latin                     sr             sr-sp                    2074          81A           1250
Sesotho (Sutu)                                                              1072          430
Setsuana                            tn             tn                       1074          432
Sindhi                              sd             sd                       1113          459
Slovak                              sk             sk                       1051          41B           1250
Slovenian                           sl             sl                       1060          424           1250
Somali                              so             so                       1143          477
Sorbian                             sb             sb                       1070          42E
Spanish - Argentina                 es             es-ar                   11274         2C0A           1252
Spanish - Bolivia                   es             es-bo                   16394         400A           1252
Spanish - Chile                     es             es-cl                   13322         340A           1252
Spanish - Colombia                  es             es-co                    9226         240A           1252
Spanish - Costa Rica                es             es-cr                    5130         140A           1252
Spanish - Dominican Republic        es             es-do                    7178         1C0A           1252
Spanish - Ecuador                   es             es-ec                   12298         300A           1252
Spanish - El Salvador               es             es-sv                   17418         440A           1252
Spanish - Guatemala                 es             es-gt                    4106         100A           1252
Spanish - Honduras                  es             es-hn                   18442         480A           1252
Spanish - Mexico                    es             es-mx                    2058          80A           1252
Spanish - Nicaragua                 es             es-ni                   19466         4C0A           1252
Spanish - Panama                    es             es-pa                    6154         180A           1252
Spanish - Paraguay                  es             es-py                   15370         3C0A           1252
Spanish - Peru                      es             es-pe                   10250         280A           1252
Spanish - Puerto Rico               es             es-pr                   20490         500A           1252
Spanish - Spain (Traditional)       es             es-es                    1034          40A           1252
Spanish - Uruguay                   es             es-uy                   14346         380A           1252
Spanish - Venezuela                 es             es-ve                    8202         200A           1252
Swahili                             sw             sw                       1089          441           1252
Swedish - Finland                   sv             sv-fi                    2077          81D           1252
Swedish - Sweden                    sv             sv-se                    1053          41D           1252
Syriac                                                                      1114          45A
Tajik                               tg             tg                       1064          428
Tamil                               ta             ta                       1097          449
Tatar                               tt             tt                       1092          444           1251
Telugu                              te             te                       1098          44A
Thai                                th             th                       1054          41E
Tibetan                             bo             bo                       1105          451
Tsonga                              ts             ts                       1073          431
Turkish                             tr             tr                       1055          41F           1254
Turkmen                             tk             tk                       1090          442
Ukrainian                           uk             uk                       1058          422           1251
Unicode                                            UTF-8                       0
Urdu                                ur             ur                       1056          420           1256
Uzbek - Cyrillic                    uz             uz-uz                    2115          843           1251
Uzbek - Latin                       uz             uz-uz                    1091          443           1254
Venda                                                                       1075          433
Vietnamese                          vi             vi                       1066          42A           1258
Welsh                               cy             cy                       1106          452
Xhosa                               xh             xh                       1076          434
Yiddish                             yi             yi                       1085          43D
Zulu                                zu             zu                       1077          435
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: DIRCTORY, ShFileOperation and Codepage <-> Keyboard Layout

Post by AUGE_OHR »

hi,

i have Problem with these Codepage :o
BACKUP.PRG(141) Error E0030 Syntax error "syntax error at 'CODEPAGE'"
BACKUP.PRG(144) Error E0030 Syntax error "syntax error at 'CODEPAGE'"
BACKUP.PRG(148) Error E0030 Syntax error "syntax error at 'CODEPAGE'"
BACKUP.PRG(152) Error E0030 Syntax error "syntax error at 'CODEPAGE'"
BACKUP.PRG(154) Error E0030 Syntax error "syntax error at 'CODEPAGE'"
BACKUP.PRG(157) Error E0030 Syntax error "syntax error at 'CODEPAGE'"

Code: Select all

139│// Problem with these Codepage ???
140│      CASE nCountry = 1038
141│         SET CODEPAGE HUNGARIAN
142│
143│      CASE nCountry = 1045
144│         SET CODEPAGE POLISH
145│         SET LANGUAGE TO POLISH
146│
147│      CASE nCountry = 2070 .OR. nCountry = 1046
148│         SET CODEPAGE PORTUGUESE
149│         SET LANGUAGE TO PORTUGUESE
150│
151│      CASE nCountry = 1049 .OR. nCountry = 2073
152│         SET CODEPAGE RUSSIAN
153│      CASE nCountry = 3098 .OR. nCountry = 2074
154│         SET CODEPAGE SERBIAN
155│         SET LANGUAGE TO RUSSIAN
156│      CASE nCountry = 1060
157│         SET CODEPAGE SLOVENIAN
---

we have "more" SET LANGUAGE TO but no "matching" Codepage :?:
we have "less" SET DATE TO but some are the sane Format ...

---

for Backup with ShFileoperation i need
SET CODEPAGE for German "Umlaute" ( > CHR (128) )
SET DATE when set "Date-Range"
and

Code: Select all

SET LANGUAGE 
only for Description
have fun
Jimmy
mlnr
Posts: 127
Joined: Fri Aug 28, 2015 1:52 pm
DBs Used: DBF

Re: DIRCTORY, ShFileOperation and Codepage <-> Keyboard Layout

Post by mlnr »

edk
Posts: 997
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: DIRCTORY, ShFileOperation and Codepage <-> Keyboard Layout

Post by edk »

I guess you need to include all the code pages you want to use.
The easiest way is to add the line in prg:

Code: Select all

#include "hbextcdp.ch" // all CodePages
Then you will be able to use

Code: Select all

SET CODEPAGE TO POLISH
...
SET CODEPAGE TO HUNGARIAN
...
SET CODEPAGE TO SLOVENIAN
...
SET CODEPAGE TO GERMAN 
...
BTW. Note the syntax: SET CODEPAGE TO POLISH
SET CODEPAGE POLISH is incorrect

As far as I remember, the native codepage names correspond to the coding variants in the Windows-nnnn format, eg POLISH is the equivalent of PLWIN (Windows-1250) ; HUNGARIAN => HUWIN (Windows-1250); SLOVENIAN => SLWIN (Windows-1250); GERMAN => DEWIN (Windows-1252); ETC

You can read the code page list with

Code: Select all

hb_cdpList ()
The system date format can be read from Locale Information:
GetLocalInfo.7z
(2.76 KiB) Downloaded 68 times
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: DIRCTORY, ShFileOperation and Codepage <-> Keyboard Layout

Post by AUGE_OHR »

hi
edk wrote: Tue Aug 17, 2021 9:59 am BTW. Note the syntax: SET CODEPAGE TO POLISH
SET CODEPAGE POLISH is incorrect
oooooh ... YES you are right ... have not "see" it
edk wrote: Tue Aug 17, 2021 9:59 am As far as I remember, the native codepage names correspond to the coding variants in the Windows-nnnn format, eg POLISH is the equivalent of PLWIN (Windows-1250) ; HUNGARIAN => HUWIN (Windows-1250); SLOVENIAN => SLWIN (Windows-1250); GERMAN => DEWIN (Windows-1252); ETC
that would have be my next Question, thx
have fun
Jimmy
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: DIRCTORY, ShFileOperation and Codepage <-> Keyboard Layout

Post by AUGE_OHR »

hi,

i have used Intormation from EKD and https://vivaclipper.wordpress.com/2014/ ... cdpselect/ to build Arrays

i do use Keyboard Language code and try to find "Windows-" or "ISO-8859-" which are "last" of matching files of Array
it does work with GERMAN

please check if it work right with "your" Keyboard Language code, thx
Attachments
CODEPAGE.ZIP
(4.96 KiB) Downloaded 82 times
have fun
Jimmy
edk
Posts: 997
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: DIRCTORY, ShFileOperation and Codepage <-> Keyboard Layout

Post by edk »

I think there is at GERMANY codepage bug on the vivaclipper site.
I guess it should be:
German 850 DE
German ISO-8859-1 DEISO
German Windows-1252 DEWIN

In my opinion, HUWIN, PLWIN, CSWIN, HRWIN (not HR1250 - another bug at viva clipper), SKWIN, SLWIN are the same Windows-1250 code page and contain the same set of characters. So for this encoding it is enough to use one of them, no matter if the language is: HU, PL, CS, HR, SK, SL.
The same will be true for DEWIN, FRWIN, ENWIN whose code page is Windows-1252.

Besides, I think, you're probably making it too complicated: the current code page can be read from Locale Information with LOCALE_IDEFAULTANSICODEPAGE

There is one more question, is the filename UTF encoded? The file may come from another OS, e.g. MacOS. Then you have to use UTF8 or UTF8EX CP

Clarification: The LCID list that I have placed may be incomplete or contain incorrect values. I found one on the internet. ;)
Last edited by edk on Wed Aug 18, 2021 9:33 pm, edited 8 times in total.
User avatar
Claudio Ricardo
Posts: 367
Joined: Tue Oct 27, 2020 3:38 am
DBs Used: DBF, MySQL, MariaDB
Location: Bs. As. - Argentina

Re: DIRCTORY, ShFileOperation and Codepage <-> Keyboard Layout

Post by Claudio Ricardo »

Hi Jimmy... Work fine for me !
Screenshot_20210818_114016.png
Screenshot_20210818_114016.png (9.49 KiB) Viewed 10445 times
but after...
Screenshot_20210818_113904.png
Screenshot_20210818_113904.png (16.83 KiB) Viewed 10445 times
Corrige al sabio y lo harás más sabio, Corrige al necio y lo harás tu enemigo.
WhatsApp / Telegram: +54 911-63016162
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: DIRCTORY, ShFileOperation and Codepage <-> Keyboard Layout

Post by AUGE_OHR »

hi,
edk wrote: Wed Aug 18, 2021 1:16 pm Besides, I think, you're probably making it too complicated: the current code page can be read from Locale Information with LOCALE_IDEFAULTANSICODEPAGE
i have search for Constant LOCALE_IDEFAULTANSICODEPAGE
what API Function is used :?: ( GetLocaleInfo, GetLocaleInfoEx, GetLocaleInfoW )
edk wrote: Wed Aug 18, 2021 1:16 pm There is one more question, is the filename UTF encoded? The file may come from another OS, e.g. MacOS. Then you have to use UTF8 or UTF8EX CP
i notice it for GERMAN "Umlaute" that ShFileOperation() does not work when set to UTF-8
when "Send to Desktop" it create Shortcut where "Verknüpfung" include "Umlaut"
Umlaute_German.ZIP
(699 Bytes) Downloaded 50 times
---

which Codepage is to use for c:\hmg.3.4.4\SAMPLES\BosTaurus\松涛館.png
what is the Problem with c:\hmg.3.4.4\SAMPLES\BosTaurus\img.png

---

i guess i will get Codepage "Number" from API Function

as i want to use it with hb_cdpselect() i guess i have to "translate" 1252 to "DEWIN" ... but 1252 can also be "Other"
so how to get right Codepage for hb_cdpselect() :idea:
have fun
Jimmy
Post Reply