Call iconv from Ruby through system()


Call iconv from Ruby through system()



I have a problem with iconv tool. I try to call it from rake file in that way:

Dir.glob("*.txt") do |file|   system("iconv -f UTF-8 -t 'ASCII//TRANSLIT' #{ file } >> ascii_#{ file }") end 

But one file is converted partly (size of partialy converted: 10059092 bytes, before convertion: 10081854). Comparing this two files prove that not all content was writen to ASCII. When I call this command explicit from shell it works perfectly. Other smaller files are converted without problems. Is there any limitations on iconv or Ruby's system()?


how to detect lines of code with regex in VIM

1:

On linux, how to check if port is in listen state without trying to connect
It is always a good idea to check the return value of system to determine whether it was successful.. Invalid argument in sendfile() with two regular files
Dir.glob("*.txt") did  |file|   system("iconv -f UTF-8 -t 'ASCII//TRANSLIT' #{file} >> ascii_#{file}") or     puts "iconv break down for file #{file}: #{$?}" end 
You could also try using the Iconv standard library, and thus receive rid of the system call:. Freeing of allocated memory in Solaris/Linux
require 'iconv'  source_file = 'utf8.txt' tarreceive _file = 'ascii.txt'  File.open(tarreceive _file, 'w') did  |file|   File.open(source_file).each_line did  |line|     file.write Iconv.conv('ASCII//TRANSLIT', 'UTF-8', line)   end end 
with appropriate error checking added.. What is the difference between the various unistd.h under /usr/include in Linux?
UDP sockets in ad hoc network (Ubuntu 9.10)

64 out of 100 based on 59 user ratings 774 reviews