2013-03-16

Drive letters

Everybody knows that Windows has mapped letters for drives and partitions. c:\windows or c:\program files are familiar notions to Windows users.

There is a big probability that you have only two drives on your computer, C: as hard drive and D: as DVD/Blu-Ray drive. The days when one had A: and/or B: drive are long gone. A: and B: were reserved for floppy disk drives. These drive letters can be reused if ones goes to „Administrative Tools -> Computer Management -> Storage -> Disk Management”.

Here is one for you: Why doesn't Windows use A: and B: for USB flash drives? It doesn't do that even if it doesn't have other letters at disposal! This has proven to be a very effective way of disabling USB flash drives from being mounted, as seen below:


The USB flash drive was insterted but Windows couldn't mount it! No error message is being given to the user either. Nothing happens!

Starting with Windows Vista by default one cannot simply create files and directories on drive C:, you either disable the UAC (User Access Control) or comply with this rule.

I used to have my hard disk partitioned as C: for Windows and other programs and D: for my projects / files. But at times I would have less space on D: and I was forced to move data to C: drive. This was a bit annoying.

After installing Windows 8 on a fresh SSD drive I've decided to have only one partition and one fake one. I've substituted a directory for a drive letter. "subst c:\users\cristian\D d:" was the magic line.

In order to change the label of my new D: drive I had to create a registry key (HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\D\DefaultLabel) and then I had the label "Data" for D: as I used with my Windows 7 system:


Unfortunately Total Commander doesn't know about this trick and it displays the same drive label for D: as it does for C:

Soon I've noticed that my emulated D: drive was visible just for me, it was not usable for programs ran as Administrator. This turned to be a letdown, I had to run "subst c:\users\cristian\D d:" from a cmd.exe shell ran as Administrator. Couldn't be a way to run this script for both users?

Fortunately "Andres" had published on stackoverflow a solution to run a cmd.exe shell script as Administrator. His solution uses a hybrid shell script which is a valid cmd.exe shell script and also a WSH JScript.

Now I had a script which runs "subst c:\users\cristian\D d:" from my user and also from the Administrator user. Cool! I've put this script in the "Start Up" and now I have a fully functional D: drive!

@if (1==1) @if(1==0) @ELSE
@echo off&SETLOCAL ENABLEEXTENSIONS
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"||(
    @subst d: %USERPROFILE%\D
    cscript //E:JScript //nologo "%~f0"
    @goto :EOF
)
@subst d: %USERPROFILE%\D
@goto :EOF
@end @ELSE
ShA=new ActiveXObject("Shell.Application")
ShA.ShellExecute("cmd.exe","/c \""+WScript.ScriptFullName+"\"","","runas",5);
@end 

I like this solution. Now when I boot my machine I see UAC prompting me to run this script, which is also a nice way to inform me that my D: drive is mounted.

2012-11-27

Aranjamente de tastatură românească

Sau altfel spus: Cum scriu cu diacritice pe Windows?

Toată lumea știe că trebuie să mergi în „Control Panel” și să configurezi tastatura la „Regional Settings”. Acest lucru este foarte adevărat. Aranjamentul de tastatură „Romanian” de pe Windows XP a devenit „Romanian (Legacy)”/„Română (Tradițională)” pe Windows Vista/7/8.

Windows Vista/7/8 vin și cu aranjamente de tastatură conforme cu standardul românesc de tastatură SR-13392:2004, și anume „Română (Standard)”, respectiv „Română (Programatori)”.

Cum rămâne cu standardul românesc de tastatură SR-13392:2004 pentru Windows XP? Pentru Windows XP (și alte versiuni mai vechi) soluția vine de la Cristian Secară. Din păcate soluția oferită necesită urmarea multor pași manuali, pași care par complicați pentru utilizatorul de rând, obișnuit cu pachete de instalare „click, click, click”.

diacritice.ro oferă o soluție asemănătoare aranjamentului „Română (Programatori)”. Din păcate soluția folosește diacriticele cu sedilă și nu implementează toată funcționalitatea oferită de standardul de tastatură, și anume linia de dialog, tastele moarte cu ajutorul cărora putem introduce caracterele altor limbi: üäößéèçô etc.

Procedura de instalare a lui „rops.exe” de pe diacritice.ro este mai simplă decât la secărică.ro, dar tot necesită la final o vizită la „Control Panel”.

Nu se poate ceva și mai simplu, conform cu standardul românesc și cu diacriticele corecte?

Cu ajutorul programului Microsoft Keyboard Layout Creator 1.4 am realizat trei pachete de instalare pentru cele trei aranjamente de tastatură:
Aranjamentele „Română (Standard)” și „Română (Programatori)” sunt identice cu cele de pe Windows 7.

Cele două aranjamente conforme standardului românesc SR-13392:2004 sunt recomandate tuturor care acum vor să învețe să scrie cu diacritice. Eu personal folosesc aranjamentul „Română (Programatori)”, sau „Română cu Alt Dreapta”. Pentru cei familiarizați cu aranjamentul moștenit de la Microsoft le recomand aranjamentul „Română (Moștenit)”.

*Aranjamentul „Română (Moștenit)” vine cu următoarele modificări față de aranjamentul „Română (Legacy)” moștenit de la Microsoft:
  • Ş și ţ cu sedilă sunt înlocuite cu ș și ț cu virgulă
  • Ghilimelele „românești” pe prima tastă de pe rândul numeric (`~), precum în aranjamentul „Română (Standard)”. Din păcate trebuie folosită tasta AltGr + `, respectiv AltGr + Shift + ` pentru a introduce: „”
  • Linia de dialog (–) pe AltGr + -
  • Tasta moartă ` (7) este activă, tastă cu ajutorul căreia se pot introduce caracterele: à, è, ù, ì, ò, À, È, Ù, Ì, Ò
  • Simbolul € pe AltGr + E
Notă: toate pachetele de instalare necesită drepturi de administrator. Windows XP necesită instalarea „Actualizării de fonturi corespunzătoare extinderii Uniunii Europene” pentru afișarea corectă a lui ș și ț cu virgulă.

Am făcut un film de prezentare a instalării aranjamentului „Română (Moștenit)”:

Windows XP


Windows 7


Pentru dezinstalare puteți fie să mergeți în „Control Panel” la „Add-Remove Programs” și de acolo să căutați „Română (Moștenit)”/„Română (Standard)”/„Română (Programatori)”, fie să rulați consecutiv pachetul de instalare.

Trebuie avut grijă doar ca aranjamentul să nu mai fie cel implicit în sistem, adică să instalați un alt aranjament de tastatură înaintea dezinstalării. Altfel mesajul de eroare poate fi foarte surprinzător pe Windows XP:



2012-11-01

Tastatura Germano-Română pentru Windows 7

De obicei românii stabiliți în Germania folosesc aranjamentul german de tastatură. Un factor important este faptul că toate tastaturile vândute în Germania vin cu acest aranjament.

Limba română este scrisă fără diacritice, deoarece nu există vreo posibilitate de a introduce diacriticele românești.

Cu ajutorul programului Microsoft Keyboard Layout Creator 1.4 am realizat un aranjament Germano-Român care are în plus:
  • AltGr + A = ă/Ă
  • AltGr + S = ș/Ș
  • AltGr + T = ț/Ț
  • AltGr + I = î/Î
  • AltGr + W = â/Â
Acest aranjament seamănă foarte mult cu aranjamentul secundar al tastaturii române (cel pentru programatori). Singura diferență este că pentru â, am folosit tasta w deoarece tasta q este deja folosită cu AltGr, pentru a genera @.

Pentru a ilustra cum funcționează vedeți gif-ul animat de mai jos:
De aici puteți descărca aranjamentul germano-român de tastatură. Pachetul de instalare suportă Windows 32bit și Windows 64bit și ar trebuit să funcționeze pe Windows XP, Vista, 7.

Tips & Tricks

Tastatura laptopului meu Dell nu are lângă tasta AltGr (Alt dreapta) decât tasta Ctrl. Alte laptopuri gen Lenovo vin cu tastaturi care au tasta meniu contextual lângă tasta AltGr, fapt care în practică dă dureri de cap celor care folosesc tasta AltGr pentru a scrie cu diacritice.

Tasta meniu contextual este relativ inutilă deoarece putem folosi combinația Shift+F10 pentru a activa meniul contextual, așa că o vom remapa ca tasta AltGr.

Pentru remapare am folosit programul KeyTweak. Mai jos avem o captură de ecran:


Mult succes în a scrie cu diacritice!

2012-08-31

Facebook + Unicode ≠ Love

The theme for the last days is the question marks instead of Unicode characters in various software products. In this case Facebook.

Facebook? Have you read this article written by Andrei Alexandrescu?

"The Best Programming Advice I Ever Got"

Coming back to question marks. I wanted to post a funny video on Facebook when I've noticed that Facebook gathered as description some undesired question marks:

If you go to the funny video (in Romanian) page you can see the caption as: „Primul șlagăr care te învață să scrii corect înjurăturile.”. No question marks there!

I'm sure there is an explanation why that happened... but it shouldn't have happened. Nobody said that Unicode is easy!

P.S. It seems Google+ does the same thing:

I was prepared to congratulate you Google on doing a better job than Facebook...

2012-08-30

MSI + Unicode ≠ Love

I was upgrading my Libre Office installation to version 3.6.1 when I've noticed the question marks in the installer UI:



How can this be? Ș and ț (s and t comma below) characters are present in the Microsoft Sans Serif and Tahoma fonts since Windows 2000.

The only explanation is: ANSI installation program. No way! You would think that Windows Installer would be Unicode, but it's not! Michael Kaplan wrote about this weirdness seven years ago: MSI Databases and Unicode?

WiX also states on their help page: „Top-level elements like Product, Module, Patch, and PatchCreation support a Codepage attribute. You can set this to a valid Windows code page by integer like 1252, or by web name like Windows-1252. UTF-7 and UTF-8 are not officially supported because of user interface issues. Unicode is not supported.”

Programs like 7-zip use MSI for x64 target because NSIS installer did not have support for x64. NSIS officially doesn't support Unicode and x64, but there are forks which do (Unicode fork, x64 fork).

I've filed a bug (#54232) for LibreOffice. I guess they will use the old ş and ţ (s and t cedilla) characters to fix this problem.

Windows 95 End of Life was 1st of January 2003, Windows 98, Windows 98 Second Edition, and Windows ME End of Life was 1st of April 2007.

They haven't fixed this problem even though is has been five years since they do not support any ANSI operating system.

2012-08-18

Qt Creator Visual C++ keyboard shortcuts

Qt Creator comes with a "MS_Visual_C++.kms" keyboard shortcuts scheme. But this scheme is not based on Visual C++ Professional, but instead of Visual C++ Express.

The two versions Visual C++ Professional and Visual C++ Express do not have the same keyboard shortcuts scheme. You can download the default keyboard scheme for Visual Studio 2010 C++ here.

If you have used Visual C++ Professional with Visual Assist you will also notice that the Visual Assist shortcuts are also missing. Visual Assist default shortcuts can be viewed here.

Visual C++ allows multiple shortcuts for the same command. Unfortunately Qt Creator doesn't allow this and at times I had to choose from multiple shortcuts only one.

Below is a table with the updates to the "MS_Visual_C++.kms" keyboard shortcuts scheme:

Command Label Shortcut Old Shortcut
Toogle Toggle Bookmark Ctrl+F2 Ctrl+K, Ctrl+K
OutputPane.nextitem Next Item F4 F6
OutputPane.previtem Previous Item Shift+F4 Shift+F6
VisualizeWhitespace Visualize Whitespace Ctrl+Shift+8 Ctrl+E, Ctrl+V
LowercaseSelection Lowercase Selection Ctrl+U Alt+U
UppercaseSelection Uppercase Selection Ctrl+Shift+U Alt+Shift+U
Sidebar.Projects Activate Projects Pane Ctrl+Alt+L Alt+X
Sidebar.Class View Activate Class View Pane Ctrl+Shift+C
AddNewFile Add New... Ctrl+Shift+A
AddExistingFiles Add Existing Files... Alt+Shift+A
RunToLine Run to Line Ctrl+F10
AttachToLocalProcess Attach to Running Local Application... Ctrl+Alt+P
FindUsages Find Usages Alt+Shift+F Ctrl+Shift+U
RenameSymbolUnderCursor Rename Symbol Under Cursor Alt+Shift+R Ctrl+Shift+R
Methods Methods and Functions Alt+Shift+S
Methods in current Document Methods in Current Document Alt+M
JumpToDefinition Follow Symbol Under Cursor Alt+G Ctrl+F12
SwitchDeclarationDefintion Switch Between Method Declaration/Definition Ctrl+F12 Ctrl+Shift+F12
SwitchHeaderSource Switch Header/Source Alt+O F4
Files in current project Files in Current Project Alt+Shift+O
Files in current project Files in Current Project Alt+Shift+O
CancelBuild Cancel Build Ctrl+ᡀ�

Cancel Build should have been Ctrl+Break. I filed this behavior as Qt Creator Bug #4609.

The complete "MS_Visual_C++_Visual_Assist.kms" can be downloaded from here. With these keyboard shortcuts Qt Creator is a able to pose as a very good substitute to Visual C++ and Visual Assist!

2012-08-05

Romanian diacritic marks in movie subtitles

One important "screen" is the TV screen. In Romania the movies are not dubbed, they are subtitled. This means that all dialogs are presented as text for the viewer to read and understand the movie.

I remember I wanted to learn how to read because I wanted to read the movie subtitles.

 

Television


By using www.cool-itv.net, which uses P2P SoapCast tehnology to distribute cable TV stations I was able to analyze which Romanian diacritics were used in movie subtitles.

Below you will see some screenshots of some TV stations:

Almost all of the TV stations used the old diacritics - S and T cedilla (şŞţŢ) - with the exception of the last one which uses the correct diacritics - S and T comma below (șȘțȚ).

The state-owned public TV broadcasters (TVR1, TVR2 and so on) did their homework and their software can handle Unicode characters and they are using the correct Romanian diacritics. Chapeau!

At least some of them use the same diacritic: Discovery, Animal Planet, ProTV, Pro Cinema, and they did not mix s cedilla with t comma below like HBO, Antena1, and Kanal D.

One interesting case was TCM which used  A Caron (ǎ) instead of A Breve (ă). Also Prima used A Tilde (ã) in their promotional clips.

The usage of the old diacritics is due to the fact that the specialized TV software used is some old software written before Microsoft started promoting Unicode.

Old software and subtitle standard from 1991 is responsible to the major usage of incorrect Romanian diacritics. The 1991 standard is the EBU (European Broadcasting Union) TECH. 3264-E  which doesn't support Unicode characters.

Hopefully all this will change with the arrival of the new EBU-TT Subtitling Specification which was announced on 31st of July 2012. In a couple of years all TV stations will be using the correct Romanian diacritics.

AVI / MKV Movies


The same grim story is presented in the underground movie subtitles scene, for example if you go to http://www.opensubtitles.org/ro and download for example Iron Sky Romanian subtitle you will get only Windows-1250 codepage subtitles. By the way Iron Sky is a cool movie :)

Nobody uses Unicode to encode the subtitles, which would not require the user to configure their media player of choice to Windows-1250 / Central European / ISO-8859-2 as default code page for subtitles.

I've created a small Windows tool (133KBytes) which automatically converts subtitles from old diacritics to correct diacritics. The tool can be downloaded from here.

Below you have a screen shot of the tool:

I hope Unicode subtitles will be more popular in the future. There is no need to stick to ANSI code pages!