Latest revision of Klib : version 2, 10.09.2014

Please find attached the second version of Klib.API.rtf.
To test or experiment, you need to download the Klib folder from 
Please download the Klib folder on a USB flash drive or a hard drive to use on your KolibriOS system.
In this version, the Klib folder contains these subfolders: 

The Klib_apps folder contains the KbTool1 application.
The Klib_fonts folder contains the unicode rasterfont files used by Klib.
The Klib_world folder contains the keyboard and other files used by Klib.
The Klibex_apps folder contains the executables of the examples is this tutorial (compiled with Fasm).
The Klibex_asm folder contains the sources of the examples in this tutorial + Klib_o2i + Klib.inc.
__________________________________________________________

About KbTool1

KBTool1 is the unicode version of the KbTool application.
The original KbTool application should still work as before.
KbTool1 depends on the files in the Klib_world folder.
The differences with the original KbTool application are:
- unicodes are shown in stead of ascii codes.
- The ascii table is dropped. Another tool will have to be made to select a unicode character (CharMap).
- The country name is looked up in an external file (Klib_world/iso3166.txt)
- The keymaps are read from an external file (Klib_world/keymaps.txt).
- The display of the codepages is dropped
- The keyboard layout selection can be memorised in Klib's keymaps file (SET Country)

Intended future enhancements to KbTool :

- enter unicode codes in hex (latex method: crtrl+shift+u+. . .)
- esperanto mode (using the x key)
- multiple keyboards (If I can obtain the keyboard enumerator)
- toggling between the selected keyboards
- alternate layout for US type keyboards.
- simple keymap editor (handy for editing the private personal keyboard layout).
- keymaps for several additional countries
- show the selected country (letters) in the status bar (the kernel has a limited set of keyboards)
- showing the country names in their own language
- show the iso name of the unicode when hoovering over the keys
- show the deadkey combinations when hoovering over a deadkey
- popup menu button with an alphabetic list of layouts per country.
- an editable textline with copy/paste for character picking.

About the keymaps.txt file

"keymaps.txt" is a utf16-coded textfile with unicodes per scancode per country.
It can be edited using NotePad, best viewed in a large monospaced font like Consolas.
The 2-letter country codes should exist in the iso3166.txt file.
There are 4 textlines per country: lowercase, uppercase,AltGr, AltGr+Shift.
The sequence of the countries is of no importance.
The sequence number and the letter code must be unique per layout.
Note: Only Klib applications can use these key layouts.
The layouts are based on MSDN publications. These are not 100% accurate.
Feedback is welcome to correct mistakes.

About the iso3166.txt file

This file is obtained from the wiki  iso 3166-1 page, saved in plain ascii, editable with NotePad.
The file lists the country names with their 2-letter code in uppercase.
The names of none-country related keyboard layouts or variations can be added, using lowercase if needed.
For example:
- AZ Azerbaijan (Latin)
- Az Azerbaijan (Cyrillic)
- La Latin Americas
- Pr Private personal keyboard layout

About the deadkey.txt file

This file contains the deadkey table in utf-16. It is hand made using Notepad.
Deadkeys are unicode combining characters needed for keyboard convertion.
Currently there are 12 deadkeys: Circumflex, Caron, Breve, Ring above, Ogonek, Dot above, Acute, Double acute, Diaeresis, Cedilla, Tilde, Grave, and x, X for Esperanto.
When enabled for a country by the  keymap, the degree key serves as ring-above.
When enabled by the keymap, the "x" and "X" keys serve as Esperanto modifier.

About the unicode font files

I intent to improve the quality of the K1r-12  font by replacing the uwe-glyphs with the glyphs of the original Kolibri system font and the cp1252 western latin raster font.
I hope that one day I find the time to make a nice 4-color-level rasterfont.
Note that now the fontsize corresponds to the em-height (lineheight) in stead of point size.

About Klib

Implementing Unicode affects all coding that involves text characters or strings.
So I thought that you better read the whole tutorial over again, rather then reading a long list of changes.
Here I only mention the major changes and enhencements of this Klib version:

About the codepages

The predefined variable cpa indicates the coding type: 0=unicode 1=cp866 2=cp1252.
I have no intention to add code pages.

About the keyboard 

From this version, Klib enters the key translation and dead-key data from external files.
The name of the files is "Keymaps.txt" and "DeadKeys.txt". 
Both files must be in the Klib_world folder on the application path.
The alt-numkey option allows the entry of numbers up to 64K.

Selecting a keyboard layout

Klib has a  routine (Sland) to select the keyboard layout for a specified country.
The selection is saved in the Keymaps.txt file ( if it is not read-only).
More then one keyboard layout can be selected.
In future, the OS will allow circling through the selected layouts using a special key combination (???).

About text edit

The text edit routines are not unicode ready yet, so I left them out of this version.
Using utf8 as default string code-format is an adventure. Future will tell . . .
To my knowledge, Fasm is not utf8 aware.
In Mas it is possible to include utf8 as well as utf16 coded unicode strings.