Difference between revisions of "iconvenc"

From Free Pascal wiki
Jump to navigationJump to search
Line 1: Line 1:
The '''iconvenc''' package is a header file for the iconv posix library on Unix. Note that this means the header tries to use the native iconv if available, GNUisms are not allowed. A simple Pascal wrapper to do a string conversion is also added.
+
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 ==
 
== Buffering ==
Line 8: Line 8:
  
 
Thanks to Thomas for his help solving this issue.
 
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
 
URLS
 
* http://www.opengroup.org/onlinepubs/009695399/functions/iconv.html  
 
* http://www.opengroup.org/onlinepubs/009695399/functions/iconv.html  
 
* http://www.gnu.org/software/libiconv/documentation/libiconv/iconv.3.html
 
* http://www.gnu.org/software/libiconv/documentation/libiconv/iconv.3.html

Revision as of 01:13, 19 July 2008

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