Difference between revisions of "iconvenc"

From Lazarus wiki
Jump to navigationJump to search
(New page: 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 si...)
 
 
(5 intermediate revisions by one other user not shown)
Line 1: Line 1:
 +
The '''iconvenc''' [[Package List|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.
  
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.
+
== 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)
 +
 
 +
== Credits ==
 +
Thanks to Thomas Schatzl for his help solving the autoflushing issue, also thanks for Ido Kanner for helping with the testing setup, and Micha Nelissen and Ales Katona for minor help and testing.
 +
 
 +
== linking 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.
 +
 
 +
== Naming ==
 +
 
 +
The unit is called iconvenc because the main function already is named iconv.
  
 
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
 +
 +
[[Category:Packages]]
 +
[[Category:Unix]]

Latest revision as of 08:56, 30 April 2013

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)

Credits

Thanks to Thomas Schatzl for his help solving the autoflushing issue, also thanks for Ido Kanner for helping with the testing setup, and Micha Nelissen and Ales Katona for minor help and testing.

linking 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.

Naming

The unit is called iconvenc because the main function already is named iconv.

URLS