2011-10-31

(ro) Algoritmi Fundamentali – O perspectivă C++

Ne aducem aminte de algoritmi de obicei în preajma vreunui interviu, și atunci vrem ceva rapid și concis.

În limba română sunt puține cărți care abordează această temă. Iar cele accesibile gratuit sunt și mai puține.

O carte accesibilă gratuit este: Algoritmi Fundamentali – O perspectivă C++ publicată de Răzvan Andonie și Ilie Gârbacea la editura Albastră în 1995.

Din păcate varianta accesibilă gratuit suferea de un mic defect – diacriticele lipseau cu desăvârșire.
Eu țineam minte că atunci când am răsfoit cartea nu am avut nicio problemă în a o citi.

După un mic dialog cu d-l Răzvan Andonie am aflat că varianta publicată într-adevăr avea diacritice, iar cea online nu. M-am oferit în a ajuta la restaurarea diacriticelor:

Cartea, erata și codul sursă al programelor C++ sunt accesibile de pe pagina d-lui Andonie. Versiunea fără diacritice mai poate fi găsită pe vechea pagină a d-lui Andonie.

2011-08-21

Windows 7 and the Romanian language

Starting with Windows Vista, Romanian language became properly supported on Windows: two new keyboard layouts were added, and font families were updated to include S comma below and T comma below characters.

Unfortunately some older fonts have some problems with S-comma below and T-comma below characters, comma is not below the S and T letter, is part of the letter. This happens also on Windows 7.

The two characters are part of Unicode's "Latin Extended-B":

I have done a simple test, to see how many fonts (from the Latin Windows fonts) have the S and T comma below characters with actual comma below symbol.

The simple test consists in a webpage rendered Internet Explorer 8 and 9 on Windows 7 with normal font size (96dpi) and with large font size (120dpi).

The test includes besides the Romanian characters (ĂÂÎȘȚăâîșț) also the "deprecated" S and T cedilla characters (ŞŢşţ) and S and T dot below characters (ṢṬṣṭ).

Test pages and screenshots for Internet Explorer 8, 9 and Firefox 5 can be found here. The results for 96dpi are presented below:
"Franklin Gothic Medium" is the only font which does not have S and T comma below characters.
"Tahoma", "Segoe UI" and "Microsoft Sans Serif" have S and T dot below characters which have the dot separated for the 9pt and 8pt font sizes, which is not true for S and T comma below characters.

The same test pages on Windows 7 with large fonts (120dpi) displayed correctly the comma for all fonts (except Franklin Gothic Medium).

Internet Explorer 9 comes with a new font renderer (using DirectWrite and Direct2D APIs) which reveals another problem with the S and T comma below characters. The comma below from S is different from the one under T, as seen in the images below:

Tahoma has a problem with A-Breve (ă), in the bold form, breve is slightly shifted to the right:


S and T cedilla characters, even tough not correct from the Romanian language point of view, are still heavily used in many documents / web pages etc. It is important that the cedilla should be drawn the same for S and T. This is not true for all Windows 7 fonts.

Firefox starting with version 4 includes locale dependent text rendering, which means that if you have the Romanian locale set the S and T cedilla characters will be automatically rendered with S and T comma below characters. Not all the Windows 7 fonts come with this locale information. Read more about this feature on Wikipedia.

The results for S and T cedilla are illustrated below:

As you have seen there is room for improvement when it comes to Romanian language support on Windows.

2011-07-29

Starting development with Qt on Windows

The general advice when it comes to start develop using Qt on Windows is to download the Qt SDK. The offline version has 1.7 Gbytes and you can start developing for Desktop (using MinGW or Visual C++ 2008 Express or higher), for Symbian ^1 or ^3 devices, or for MeeGo devices.

People usually complain about the size of the offline Qt SDK. In comparison Visual Studio 2008 Standard Edition (x86) - DVD (English) has 2,8 Gbytes.

Even though the offline Qt SDK has 1.7 GBytes, it doesn't include everything. The precompiled Qt demos are not included in Qt SDK. They are available though through the individual Qt Library installers, or more explicitly Qt libraries 4.7.3 for Windows (VS 2008, 228 MB).

After installation one can use Qt Creator to develop applications. I won't go into much detail here, one can browse through the official documentation - Qt Creator Manual 2.2.1

I'm going to describe how you can compile from command line programs for Desktop - MinGW, Visual C++ 2008, and for Symbian^3.

First we need to get a small "Hello World" example. Google pointed out at Qt 4.3: Qt Tutorial 1.
We need to start up a text editor and paste:
#include <QApplication>
#include <QPushButton>

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QPushButton hello("Hello world!");
    hello.resize(100, 30);

    hello.show();
    return app.exec();
}

From Start Menu -> All Programs -> Qt SDK -> Desktop you can start the command prompt for "Qt 4.7.3 for Desktop (MinGW)". Unfortunately it lands into c:\windows\system32

Since I already use Total Commander for my file browsing I've decided to copy the properties from the Qt Command Prompts into Total Commander's Start Menu.

If we do not specify a "Start path" for an entry in Total Commander's Start Menu, Total Commander will use the current directory as start path, which together with a hot key will free me from useless mouse clicking and of some typing.

"Qt 4.7.3 for Desktop (MinGW)" is a shortcut for "C:\Windows\System32\cmd.exe /A /Q /K C:\QtSDK\Desktop\Qt\4.7.3\mingw\bin\qtenv2.bat". Copying the command line into Total Commander's Start Menu looses one functionality - the title of the command window becomes "c:\windows\system32\cmd.exe" compared with the Qt SDK's "Qt 4.7.3 for Desktop (MinGW)". This can be easily fixed by appending "title Qt 4.7.3 for Desktop (MinGW)" into "C:\QtSDK\Desktop\Qt\4.7.3\mingw\bin\qtenv2.bat".

Now that we have everything in place we can type into "Qt 4.7.3 for Desktop (MinGW)" command window the following commands (in the directory where we saved the "Hello World" source code):
qmake -project
qmake
mingw32-make

The result is presented bellow:

I've done the same for "Qt 4.7.3 for Desktop (MSVC 2008)". The commands to build the "Hello World" application are almost the same, but instead of mingw32-make, nmake is to be used with MSVC 2008.

But after running nmake the following message was displayed:
'nmake' is not recognized as an internal or external command, operable program or batch file.

This is due to the fact that "C:\QtSDK\Desktop\Qt\4.7.3\msvc2008\bin\qtenv2.bat" does not setup the MSVC 2008 compiler. In order to fix this append the lines to the qtenv2.bat file:
call "%programfiles%\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat"
title Qt 4.7.3 for Desktop (MSVC 2008)

For Symbian^3 instead of making a shortcut to cmd.exe and pass the batch file as argument, there is a shortcut to the batch file: "C:\QtSDK\Symbian\SDKs\Symbian3Qt473\bin\qtenvS3.bat", which in turn makes a call to cmd.exe. Exactly the opposite. Edit qtenvS3.bat and replace the last line "cmd /A /Q /K" with the lines:
popd
title Qt 4.7.3 for Symbian^3 Command Prompt

Compiling the "Hello World" sample for Symbian^3 goes like this (helloqt.cpp needs to be on the same drive where Qt SDK was installed, e.g. c:\):
qmake -project
qmake
make release-gcce
make sis

After installing helloqt.sis on device, the result looks like this (admittedly not a very good looking screen shot):


Compiling Qt applications from command prompt is important in cases in which we have to deal with configure scripts, or when we want to do things "old school" :)

I've opened up a bug report QTSDK-802 with the issues presented in this blog entry.

2011-07-03

(ro) Firefox și diacriticele vechi și noi

Recent s-a lansat www.cațavencii.ro www.catavencii.ro, și pentru un sit nou nouț mi s-a părut înapoiată alegerea de a folosi diacriticele vechi cu sedilă, mai ales când există soluții tehnice pentru rezolvarea problemei pătrățelelor în navigatoarele mai vechi. Dar sedile din titlurile articolelor arătau foarte corect în Firefox.

Am făcut două capturi de ecran pentru Firefox 5 și Google Chrome 12 și le-am pus într-un gif animat:

Google Chrome afișa pagina cu sedile, precum Opera 11.50 și Internet Explorer 9.0. Inițial am crezut că este vorba de un bug și l-am raportat #668996, dar s-a dovedit că nu este un bug ci un/o „feature”!

Firefox începând cu versiunea 4 randează textul în funcție de limba aleasă pentru setările locale din sistem. Din păcate nu toate fonturile din Windows 7 vin cu această facilitate, asta explică de ce fontul „Times New Roman” din animația de mai sus și-a păstrat diacriticele cu sedilă.

Alte situri precum www.capisci.ro sunt desedilizate complet. Vezi articolul despre diacritice:


Cei de la capisci au această notă „Textul articolului este scris intenţionat cu semne diacritice greşite la literele ş şi ţ pentru a permite citirea lui de către aceia care probabil sînt cei mai interesaţi de subiect, adică aceia care văd pătrăţele în locul literelor corespunzătoare cu diacritice corecte.” :)

Pentru a preveni înlocuirea automată codul html trebuie să conțină indicații despre limbă precum lang="en".

În viitorul apropriat sistemele de operare vor avea toate fonturile actualizate și cel puțin Firefox va afișa internetul românesc corect!

Merită totuși menționat faptul că acest lucru se poate face acum cu ajutorul extensiei FoxReplace! Eu am ales să fac conversia manual, apăsând tasta F2. Puteți importa direct fișierul meu de configurare.

2011-06-30

European Registrars

In May 2010 I've found out that the Moldavian registrar (ccTLD) allows Internet domain names containing Romanian characters. By contrast, the Romanian ccTLD does not allow Internet domain names containing Romanian characters.

I've asked the Romanian ccTLD why is that so, and their reply was: (sorry for the Google translation, didn't feel like translating this)
Currently we do not allow diacritics in domain names because there are two standards (alphabetically) for Romanian, ISO-8859-2 (tilde) and ISO-8856-16 (comma), Legacy and proper Romania keyboard Standard, and is impossible to work with two incompatible standards between them.

At this point
ISO-8859-2 is depreciated with software makers obligation to provide support for ISO-8856-16. However, ISO-8859-2 is currently used in more than 90% and
expected to decrease below 50%. We can not predict at this time, but when most will use the correct character set will Romanian IDN domains allows registering the subset latin2.

I've asked myself how many countries in Europe allow national characters in their Internet domain names, this was after I've found out that starting with 10th of December 2009 the European Union (.eu) registrar offered support for all official EU languages.

After a bit of research I've come up with this map of Europe. Green is for Countries that allow national characters in domain names, Pink for those which allow only the American Standard Code for Information Interchange (US-ASCII) characters.


I've took some notes which can be found here.

I've learned that European Union (.eu) and Slovenian (.si) registrars allow domain names with proper (comma) Romanian characters, while the German (.de) and Moldavian (.md) registrars allow domain names with the deprecated (cedilla) Romanian characters.

The last registrar to allow Internationalized Domain Names (IDNs) was the Estonian ccTLD:
Starting from June 13, 2011 the Estonian Internet Foundation will bring letters with diacritical marks õ, ä, ö, ü, š and ž to national domains ending with the suffix .ee, which means that the .ee domain will be covered with the full range of the Estonian alphabet. The Estonian Internet Foundation in cooperation with the Association of the Estonian Patent Attorneys has introduced a period for reservation of .ee domain names containing letters with diacritical marks before commencement of general registration of such domain names.

The sad part is that the Romanian registrar announced on 15th of June 2008 that they've updated their system, the interesting part was at 11. (again sorry for the Google translation):
11. The new system is ready to allow the registration of domain names with diacritics in Romanian. But these services will be provided in a later stage once they have established and accepted rules of domain registration with diacritics.

Next time you pay for your domain name, don't forget to ask them about how long it will take to establish the rules of domain registration with diacritics. It's been more than three years since they announce it.

P.S. One might think that the reason that the Romanian ccTLD doesn't allow the Romanian special characters could be the fact that it waits after ICANN to approve the Romanian characters. This is not the case, as you can see here signed by the hand of the «Head of .RO Registration Services», because of "NOT BEING ELIGIBLE FOR FAST TRACK. The Romanian diacritics are included in the Latin script".

A Romanian  version of this post was published in Kamikaze Online.

2011-06-21

A-Breve

At Qt Contributor's Summit in Berlin I've got the chance to meet the man behind Qt's port on Android.

The first thing I've noticed was a small change on his ID tag. His name was spelled differently it was not "Bogdan Vatra" as seen everywhere but instead was "Bogdan Vatră", which makes more sense giving that he's Romanian.

Now I've fixed the injustice of having no results on Google when searching the correctly spelled name!

Bogdan, keep up the good work and don't be shy on using your correctly spelled name. A-Breve is correctly displayed on all systems.

2011-06-16

2011-05-28

(ro) Tastaturi românești

Pe la începutul anilor 2000 am văzut prima tastatură cu aranjament românesc, era o tastatură BTC. comRACE încă mai vinde acele tastaturi BTC. Aranjamentul era cel oferit de Microsoft în acei ani.

Deși mi-am dorit o tastatură cu aranjament românesc nu am cumpărat-o, fiind obișnuit cu aranjamentul american (y era la y, z era la z).

În timp lucrurile au evoluat astfel:
  • Apr 1993 Microsoft lansează Windows 3.1 pentru Europa Centrală și de Est (vezi cum arăta tastatura virtuală).
  • Jun 1993 IBM introduce aranjamentul KBD446, aranjament folosit în sistemul de operare OS/2
  • Ian 1998 ASRO (IRS pe vremea aceea) introduce standardul de tastatură românească SR-13392:1998
  • Sep 1999 Unicode 3.0 atestă existența caracterelor ș și ț cu virgulă
  • Ian 2001 Cristian Secară publică aranjamente de tastatură mai omenești, având la bază standardul ASRO SR-13392:1998 (vezi pagina din Iunie 2002)
  • Dec 2004 ASRO revizuiește standardul de tastatură - 13392:2004
  • Ian 2007 România intră în Uniunea Europeană
  • Ian 2007 Microsoft lansează Windows Vista cu suport pentru standardul ASRO SR-13392:2004, vechiul aranjament oferit de Microsoft rămâne sub denumirea „Legacy”
  • Mai 2007 Windows XP poate fi actualizat pentru a afișa ș și ț cu virgulă (doar fonturile, nimic de-a face cu tastatura)
  • Oct 2009 Microsoft lansează Windows 7. În Ian 2010 Microsoft declara Windows 7 cel mai bine vândut sistem de operare din istorie.
  • Mai 2010 Google adaugă o tastatură virtuală la www.google.ro. Din păcate Google au ales aranjamentul IBM KBD446 ca model, ignorând cu succes standardul românesc. Am raportat problema aici (Nov 2010). Google a adăugat aranjamentele ro_sr13392_primary și ro_sr13392_secondary conforme standardului românesc. Sep 2013 www.google.ro are cele două aranjamente conforme cu standardul prezente în Google Chrome, Internet Explorer, dar nu în Firefox.
  • Oct 2013 Firma WASD Keyboards produce prima tastatură conformă cu aranjamentul secundar din standardul ASRO SR-13392:2004.
Cherry și Fujitsu/Siemens au produs tastaturi conforme standardului ASRO SR-13392:1998 și în 2011 te-ai aștepta să găsești tastaturi conforme standardului ASRO SR-13392:2004. Laptopuri cu tastaturi s-au mai văzut (Toshiba este singurul exemplu) dar tastaturi pentru PC... nț.

Am fost plăcut surprins să aflu că un producător de talie mondială - DELL - are o ofertă europeană completă de tastaturi, printre care și tastaturi „mioritice”.

Dell are patru tastaturi românești în ofertă:

Tastatura multimedia 580-13630 (QWERTY)  
Tastatura normală 580-14797 (QWERTZ)
Tastatura multimedia extra 580-14246 (QWERTY)
Tastatura normală 580-15060 (QWERTY)
Din păcate tastaturile au poze generice și nu se poate observa ce aranjament este folosit. Trei din ele menționează faptul că ar fi QWERTY - adică respectând noul standard. Singura metodă de a afla a fost să comand o tastatură.

Tastaturile pot fi comandate doar telefonic de la Dell, respectiv de la distribuitorii Dell din țara în care locuiți. Pentru Germania numărul de telefon este: 0 800 33 55 66 1, apelul fiind netaxabil. Teoretic o tastatură românească poate fi obținută în două săptămâni în orice țară în care Dell vinde calculatoare.

Am comandat tastatura normală 580-14797 (22€), dar deoarece în descriere era menționat faptul că ar fi aranjamentul vechi (QWERTZ), am schimbat comanda pentru tastatura multimedia extra 580-14246 (33€)

Din păcate aranjamentul este tot cel vechi, chiar dacă în descriere este menționată descrierea QWERTY, precum se vede din poza de mai jos:


În poză nu se observă cele două porturi USB, foarte utile când avem de-a face cu memorii portabile USB sau cu noile telefoane cu alimentare prin cablul USB.

Am contactat telefonic Dell și le-am comunicat faptul că există o problemă cu descrierea produsului. Din păcate Dell nu are în ofertă tastaturi cu noul standard. Vânzătorul a fost surprins să afle că aranjamentul oferit este vechi. Pentru necazul provocat Dell mi-a făcut cadou tastatura!

Am obținut gratis o tastatură de 33€, o tastatură de care nu am nevoie și sunt dispus să o donez cuiva căreia i-ar fi folositoare.

Producătorii de calculatoare ar avea de câștigat din vânzarea tastaturilor compatibile cu „Windows 7”, respectiv conforme standardului ASRO 13392:2004.

Dragi producători ne-am săturat de tastatura Microsoft „Legacy”!

P.S. Statele Unite ale Americii

Se pare că tastatura 580-14246 are un alt cod în Statele Unite ale Americii și anume W316D. Pe ebay se poate cumpăra o tastatură W316D la numai $19,95.

P.P.S. Alți producători

Și firma Lenovo, firmă care a achiziționat divizia de calculatoare de la IBM în anul 2005, are în ofertă tastaturi românești.

Oferta conține cinci tastaturi:
IBM Enhanced Performance USB Keyboard (Business Black) - Romanian 446 73P2644
ThinkPlus Preferred Pro USB Fingerprint Keyboard - Romanian 446 73P4754
IBM Enhanced Performance USB Keyboard (Business Black) - Romanian 096 73P2645
Lenovo USB Smartcard Keyboard - Romanian 51J0182
Lenovo USB Smartcard Keyboard - Romanian 51J0183

Tastatura ThinkPlus Preferred Pro USB Fingerprint arată astfel:

Putem doar specula faptul că „Romanian 446” vine de la standardul IBM KBD446.

Și firma HP are în ofertă cel puțin o tastatură românească, și anume „HP 2004 Standard Keyboad USB RO” DT528A#AKE. Se poate găsi la Amazon DE la prețul de 19,49€

Tastatura DT528A arată astfel:
Cu siguranță avem de-a face cu o tastatură „Legacy” deoarece în descrierea de pe pagina Amazon UK este menționat la sistemul de operare „Microsoft Windows 2000 / XP”.

Actualizare: (Sep 2013) HP are în ofertă începând cu Feb 2011 modelul HP 537746-271, se poate găsi la Amazon DE la prețul de 39€. Poza de pe Amazon DE arată exact la fel ca poza de mai sus  modelului DT528A#AKE.

Și firma Acer oferă tastaturi românești:

Keyboard Romanian 105-key USB KB.USB0B.073
Keyboard Romanian 105-key Wireless KB.RF403.057
Keyboard Romanian 105-key RoHS USB KB.KUS03.260
Keyboard Romanian 105-key Black USB KB.USB03.092
Keyboard Romanian 105-key Black PS2 KB.PS20B.005
Power Series SK50 KB.6880B.075

Aspire Z5600 KB.RF403.274
Aspire X3600 KB.KUS03.260

La tastaturile Acer nu am putut găsi detalii despre aranjamentul folosit, cel mai probabil avem de-a face de asemenea cu aranjamentul „Legacy”.

Actualizare:  firma Fujitsu are în ofertă o tastatură conformă cu standardul românesc, pentru mai multe detalii mergeți la: Tastaturi românești II.

2011-05-23

Android is the new Windows Mobile

Firstly please excuse me for stating the obvious. I've reached the above conclusion after seeing Android ports of two Windows Mobile programs.

Windows Total Commander has a beta version for Android. Total Commander for Windows Mobile is a nice addition to the native File Explorer, one feature I use often is the Registry Editor. On the desktop I use Total Commander daily, and I feel like missing one hand when I have to operate on desktops without it.

The second application with an Android port (and also an iPhone port) is Birdie Sync, which allows synchronization between your mobile phone and Mozilla Thunderbird / Sunbird.

It's nice to see that these applications are brought to life on a different platform. What Windows Mobile applications ported to Android have you encountered?

2011-05-04

Thank you Google!

Google has finally fixed the Droid font family with regard to Romanian language (reported as a bug here). The font family can be downloaded from here, and more information about the release can be found here.


What came as a surprise was the fact that Google Web Fonts had proper Romanian support for Droid font family. This was not the case in the past, and still not the case for other font families like Ubuntu (reported as a bug here)


Thank you Google! (I would have welcomed a comment in the bug report though)

P.S. Google Web Fonts are not yet updated to cope with Romanian language. The picture above shows what one should expect (also when the font is installed in the system), and below is what one will really get.

2011-02-27

Thank you Amazon!

In this post I'm focusing on Kindle for PC running on Windows XP and the Romanian language.

Windows XP has been able to display correct Romanian characters after Romania joined the European Union in 2007, and it can do this after installing the European Union Expansion Font Update.

Here is a screenshot of Kindle for PC 1.2.1 displaying a book on Windows XP:


Here is a screenshot of Kindle for PC 1.3.0 displaying the same book:


Noticed the squares? They are there because Amazon changed the font (which cannot be changed by user) from Times New Roman to Georgia. Unfortunately Microsoft has not included an updated version of Georgia in the "European Union Expansion Font Update".

Here is a list of options for fixing this squares problem:
  1. Upgrade from Windows XP to a newer Windows operating system
  2. Report the problem to Microsoft and hope for a new version of  "European Union Expansion Font Update"
  3. Report the problem to Amazon and hope for a new version of Kindle for PC

The first option is not always feasible due to old hardware or lack of budget for newer Windows operating systems.

The second option could have worked in 2007, but not in 2011. I'm saying this because the first version of "European Union Expansion Font Update" was dated 8 December 2006 and included font updates for Arial, Times New Roman, and Verdana families. The second version is dated 1 May 2007 which also added the Trebuchet font family to the updated font list.

The third seems the most "doable" of them all. And it was.

Here is a screemshot of Kindle for PC 1.4.1 running on Windows XP:


Amazon reverted the reading font to Times New Roman. Thank you Amazon for listening! (although feedback like "We fixed your problem in version x.y.z" would have been welcomed)

2011-02-09

Reusing bits

I was cleaning my projects directory and I have stumbled upon a small piece of code which I thought might interest others.

The small piece of code was about changing a private data member from outside the object, using normal C++, without using reintepret_cast or hacks like #define class struct


#include <iostream>

class Pi
{
    double pi_;
public:
    Pi() : pi_(3.1514f)
    {
    }

    double GetValue() const
    {
        return pi_;
    }
};

struct Pie
{
    double pie_;
};

int main()
{
    using std::cout;
    using std::endl;

    Pi pi;
   
    cout << "Pi: " << pi.GetValue() << endl;

    Pie* p = new (&pi) Pie;
   
    p->pie_ = 4.0f;

    cout << "Pi: " << pi.GetValue() << endl;
}

I have highlighted the line which does the trick. This trick is called placement new.

2011-01-18

Manifest this

In this blog entry I will talk about Visual Studio 2008 and the C runtime library.

Firstly we create a new Win32 hello world console application:

#include <iostream>

int main()
{
    std::cout << "Hello World" << std::endl;
}

The resulted hello.exe binary is 9KB large, and by using Dependency Walker we find that is dynamically liked to msvcp90.dll, msvcr90.dll, and kernel32.dll

One might think that in order to deploy this hello application you will only need msvcp90.dll and msvcr90.dll alongside the application, or to have them somehow installed in the system.

The latter option is preferred by most applications, you only need to install Microsoft Visual C++ 2008 Redistributable Package and that's it.

The redistributable package is 1.7MBytes in size, and is installed in c:\Windows\WinSxS directory, and it also includes MFC. But this is just a hello world application, surely we don't need to install MFC.

The good news is that you can copy from C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT\ only msvcp90.dll, msvcr90.dll, and the funnily file named Microsoft.VC90.CRT.manifest. You don't need to copy msvcm90.dll because this is required for "Managed" C++ applications.

The manifest file is required because starting with Visual Studio 2005 the C runtime library (CRT) is packaged as Side-by-side Assembly. Applications need to have also a bit of magic in order to work with the new CRT namely the RT_MANIFEST resource embedded in the executable.

By using Resource Hacker we can take a peek at this RT_MANIFEST section:

<assembly manifestversion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
  <trustinfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedprivileges>
        <requestedexecutionlevel level="asInvoker" uiaccess="false"></requestedexecutionlevel>
      </requestedprivileges>
    </security>
  </trustinfo>
  <dependency>
    <dependentassembly>
      <assemblyidentity name="Microsoft.VC90.CRT" processorarchitecture="x86" publickeytoken="1fc8b3b9a1e18e3b" type="win32" version="9.0.21022.8"></assemblyidentity>
    </dependentassembly>
  </dependency></assembly>

I have highlighted the version of  the CRT used.

What happens if you decide to install Visual Studio 2008 SP1? You would expect that you should have a different CRT version. That was the case for Visual Studio 2005, Visual Studio 2008 uses the RTM version also when you install SP1, as described in this Visual C++ Team Blog article.

The size of the Microsoft Visual C++ 2008 SP1 Redistributable Package changed as well, from 1.7MB to 4.0MB due to MFC Facelift... Feature Pack and C++ TR1 inclusion.

In order to have the new CRT referenced one needs to set the following preprocessor define _BIND_TO_CURRENT_CRT_VERSION. After doing so the CRT version becomes 9.0.30729.1.

After Visual Studio 2008 SP1 there was another CRT update due to ATL Security Update, which bumped the CRT version to 9.0.30729.4148. This version is referenced in "c:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT\Microsoft.VC90.CRT.manifest"

So we have build our hello application with version 9.0.30729.1 and we distribute the CRT with version 9.0.30729.4148, which of course doesn't work in practice.

Others have encountered this problem and they have taken drastic measures like reinstallation of Visual Studio 2008 and/or manually change the CRT version in "c:\Program Files\Microsoft Visual Studio 9.0\VC\include\crtassem.h" header file.

Since these manifest files are xml files why not just change them using the manifest tool?

The following two commands extract and repack the RT_MANIFEST resource:
mt.exe -inputresource:hello.exe;#1 -out:hello.manifest
mt.exe -outputresource:hello.exe;#1 -manifest hello.manifest

Now there is the issue of replacing "9.0.30729.1" to "9.0.30729.4148" in hello.manifest and since sed is not present on a normal Windows machine I have created a Javascript script which does this task, which is called like this:

cscript.exe replace_string.js hello.manifest "9.0.30729.1" "9.0.30729.4148"

This way we can update the CRT files without having to wait for Visual Studio to catch up.

They say Visual Studio 2010 has addressed the whole manifest nightmare and one can copy the CRT files alongside the executable file without any hacking.

2011-01-06

ActiveX <video> controls

The recently released OpenCodecs release, beside fixing bugs and updating audio and video codecs libraries adds support for "controls" attribute in the ActiveX <video> player.

Without further ado here is a video showing this feature:


The ActiveX <video> player uses DirectShow to render an URL. The DirectShow "File Source (URL)" filter downloads a file from beginning to the end and it doesn't support seeking until has downloaded the whole file. This behavior is unfortunate and I hope I can fix this by writing my own "File Source (URL)" filter.

The above video presents a Theora video, which at first it has 0:00 length and then it has the right duration. This is due the fact that the current DirectShow Ogg demuxer needs to have access to the whole file in order to build the seeking table, the ActiveX player knows when the download is completed and builds the seeking table at the end. WebM should not have this limitation.

The UI was borrowed from Firefox and I've used GDI+ to draw the controls. I hope to use Cairo in a future version, in order to have prettier controls and to share it with the Kate subtitles decoder.

This should make the ActiveX player a bit more usable. In the next version besides having a new URL source filter I plan to add scripting support in order to control the ActiveX player from JavaScript code.