profile picture

3 pages tagged with "c"

Catching a Leap Second

January 01, 2009
As you may know there is such a thing as a leap second, and Dec 31 2008 is a day with a leap second. A couple of hours before New Year I got an idea to catch this leap second. The problem is that Linux uses Unix time and thus ignores leap seconds. Hence if you use time(2) or gettimeofday(2), the lea… read more

More about UTF-8

August 02, 2008
Now suppose you want to rid string of malformed utf-8 characters. Here is an example that checks an utf-8 string and replaces all malformed characters with '?'. The same idea as in the previous post. Note, that it checks only encoding, it is possible that encoding is correct, but the symbol doesn't … read more

How to truncate UTF-8 string

July 16, 2008
<p>Suppose you need to put UTF-8 string into a fixed length buffer. Actually I was in need to do this. Problem is that the last symbol may be incomplete, so here is the example how to do this read more