Archive for the ‘string’ category

Testing Finnish National identification number (SOTU)

January 5, 2007

Here’s a sample function to test the validity of Finnish National identification number (henkilötunnus (HETU)), formerly known as sosiaaliturvatunnus (SOTU)).


Reading “DOS files”

December 12, 2006

Today I received a TXT file created from some DOS application and I have to read the data into InterBase database. Everything was fine until I discovered that umlaut characters (ä, ö, etc) end up with totally different symbols („,”, etc). Win32 API helped me this time as well – OemToChar() and OemToCharBuff() are the functions to look:

The OemToChar function translates a string from the OEM-defined character set into either an ANSI or a wide-character string.

And a simple code example as well:

if s <> '' then
  OemToChar(PChar(s), PChar(s));

Beware not to pass an empty string to the function! Try out to see what happens 😉