iconvenc

From Free Pascal wiki
Revision as of 01:13, 19 July 2008 by Marcov (talk | contribs)
Jump to navigationJump to search

The iconvenc package is a header file for the POSIX iconv posix library on Unix. Note that currently we try to keep this header portable, so GNUisms are not allowed. A simple Pascal wrapper to do a string conversion is also added.

Buffering

While creating the header, some confusion arose over the fact that the library didn't always seem to write the last few chars. This turned out to be a buffering in the iconv lib, which isn't really spellled out in the man pages (though the below URLs do mention it cryptically).

The lib does autoflushed if the input string is 0 terminated (IOW if the count of chars to be passed is strlen(pchar)+1 or length(ansistring)+1), but an additional iconv(nil,nil,dest,outcharcount); will flush the buffer. (see the iconvert routine)

Thanks to Thomas for his help solving this issue.

link method

The header file allows both dynamic as static linking, with static being the default. {$define loaddynamic} to make it try multiple libraries. A function to try additional library names is also provided.

URLS