Google Groups Home
Help | Sign in
Another encoding problem
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  20 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
zzzer  
View profile
 More options 9 Jul, 10:48
From: zzzer <f...@free.fr>
Date: Wed, 9 Jul 2008 02:48:14 -0700 (PDT)
Local: Wed 9 Jul 2008 10:48
Subject: Another encoding problem

Hello,

I've developed a ruby RGhost program that generates barcodes and text.

I've written it when I was on Ubuntu, and now, I want to make it work
on Windows.

But when I execute the file, there's some trouble :

C:\Documents and Settings\Administrateur\Bureau>ruby zcb.rb
c:/ruby/lib/ruby/gems/1.8/gems/rghost-0.8/lib/rghost/
ruby_ghost_config.rb:67:in `iconv': invalid encoding ("latin1",
"utf8") (Iconv::InvalidEncoding)
        from c:/ruby/lib/ruby/gems/1.8/gems/rghost-0.8/lib/rghost/
ruby_ghost_config.rb:67
        from c:/ruby/lib/ruby/gems/1.8/gems/rghost-0.8/lib/rghost/
ruby_to_ps.rb:16:in `call'
        from c:/ruby/lib/ruby/gems/1.8/gems/rghost-0.8/lib/rghost/
ruby_to_ps.rb:16:in `pack_string'
        from c:/ruby/lib/ruby/gems/1.8/gems/rghost-0.8/lib/rghost/
ruby_to_ps.rb:7:in `to_string'
        from c:/ruby/lib/ruby/gems/1.8/gems/rghost-0.8/lib/rghost/
parse_text.rb:45:in `ta_entry'
        from c:/ruby/lib/ruby/gems/1.8/gems/rghost-0.8/lib/rghost/
parse_text.rb:32:in `text_to_ps'
        from c:/ruby/lib/ruby/gems/1.8/gems/rghost-0.8/lib/rghost/
parse_text.rb:29:in `each'
        from c:/ruby/lib/ruby/gems/1.8/gems/rghost-0.8/lib/rghost/
parse_text.rb:29:in `text_to_ps'
        from c:/ruby/lib/ruby/gems/1.8/gems/rghost-0.8/lib/rghost/
parse_text.rb:27:in `map'
        from c:/ruby/lib/ruby/gems/1.8/gems/rghost-0.8/lib/rghost/
parse_text.rb:27:in `text_to_ps'
        from c:/ruby/lib/ruby/gems/1.8/gems/rghost-0.8/lib/rghost/
text.rb:37:in`ps'
        from c:/ruby/lib/ruby/gems/1.8/gems/rghost-0.8/lib/rghost/
ps_object.rb:41:in `set'
        from c:/ruby/lib/ruby/gems/1.8/gems/rghost-0.8/lib/rghost/
ps_facade.rb:166:in `text'
        from zcb.rb:55:in `creeCodeBarre'
        from zcb.rb:146
        from zcb.rb:142:in `foreach'
        from zcb.rb:142

I really don't know why it bugs, because on Ubuntu there isn't any
problem...
Here's my code :

require 'rubygems'
require 'rghost'
require 'rghost_barcode'

include RGhost

def creeCodeBarre (ligneFichier)

        # Initiation des variables lues dans le fichier, forme :
        # num_finess ; nomES ; numService ; libelleService ; rpps_chef ;
nomChef ; rpps_prescripteur ; nomPrescripteur
        num_finess=ligneFichier[0]
        nomES=ligneFichier[1]
        numService=ligneFichier[2]
        libelleService=ligneFichier[3]
        rpps_chef=ligneFichier[4]
        nomChef=ligneFichier[5]
        rpps_prescripteur=ligneFichier[6]
        nomPrescripteur=ligneFichier[7]

        nomPrescripteur = nomPrescripteur.chomp

        x_finess=20
        y_finess=3
        rotation_finess=90
        hauteur_finess=1

        x_rpps_prescripteur=20
        y_rpps_prescripteur=22
        rotation_rpps_prescripteur=90
        hauteur_rpps_prescripteur=1

        x_chefService=20
        y_chefService=12
        rotation_chefService=90
        hauteur_chefService=1

        doc=Document.new

        texteInfos = 'num_finess : ' + num_finess + '<br/>nomES : ' + nomES +
'<br/>numService : ' + numService + '<br/>libelleService : ' +
libelleService + '<br/>rpps_chef : ' + rpps_chef + '<br/>nomChef : ' +
nomChef + '<br/>rpps_prescripteur : ' + rpps_prescripteur + '<br/

>nomPrescripteur : ' + nomPrescripteur

        doc.text texteInfos

        doc.define_tags do
                tag :font1, :name => 'Times', :size => 10, :encoding => true
        end

        #-------------
        # Génération du code barre Finess si le numéro Finess existe

        if num_finess != ''
                doc.barcode_code128('^105 ' + num_finess,
                                        :x => x_finess,
                                        :y=> y_finess,
                                        :text=>{:size=>10},
                                        :height => hauteur_finess,
                                        :rotate => rotation_finess)

                # Ecriture de "Numéro Finess" au dessus du code barre
                doc.moveto :x => (x_finess-1.1), :y => (y_finess+0.5)
                doc.rotate 90
                doc.show("Numero Finess",  :with => :font1)
                doc.rotate -90
        end
        #-------------

        #-------------
        # Génération du code barre du chef de service si le rpps_chef
existe

        if rpps_chef != ''
                doc.barcode_code128('^105 ' + rpps_chef,
                                        :x => x_chefService,
                                        :y=> y_chefService,
                                        :text=>{:size=>10},
                                        :height => hauteur_chefService,
                                        :rotate => rotation_chefService)

                # Pour un numéro RPPS, la zone de texte où écrire s'étend de
y_chefService à y_chefService+3.5, et un caractère = 0.15 de largeur
                milieu=1.75
                largeurNomEnCaracteres=nomChef.size
                largeurNomEnCm=largeurNomEnCaracteres*0.15
                pointDeDepart=milieu-largeurNomEnCm/2

                # Ecriture du nom du chef de service au dessus du code barre
                doc.moveto :x => (x_chefService-1.1), :y => (y_chefService
+pointDeDepart)
                doc.rotate 90
                doc.show(nomChef,  :with => :font1)
                doc.rotate -90
        end
        #-------------

        #-------------
        # Génération du code barre RPPS du prescripteur si
rpps_prescripteur existe

        if rpps_prescripteur != ''

                doc.barcode_code128('^105 ' + rpps_prescripteur,
                                        :x => x_rpps_prescripteur,
                                        :y=> y_rpps_prescripteur,
                                        :text=>{:size=>10},
                                        :height => hauteur_rpps_prescripteur,
                                        :rotate => rotation_rpps_prescripteur)

                # Pour un numéro RPPS, la zone de texte où écrire s'étend de
y_chefService à y_chefService+3.5, et un caractère = 0.15 de largeur
                milieu=1.75
                largeurNomEnCaracteres=nomPrescripteur.size
                largeurNomEnCm=largeurNomEnCaracteres*0.15
                pointDeDepart=milieu-largeurNomEnCm/2

                # Ecriture du nom du professionnel au dessus du code barre
                doc.moveto :x => (x_rpps_prescripteur-1.1), :y =>
(y_rpps_prescripteur+pointDeDepart)
                doc.rotate 90
                doc.show(nomPrescripteur, :with => :font1)
                doc.rotate -90
        end
        #-------------

        # Remplacement des éventuels espaces par des points dans
nomPrescripteur
        nomPrescripteur = nomPrescripteur.gsub(' ', '.')

        nomDuFichier = rpps_prescripteur.to_s + '.' + nomPrescripteur +
'.pdf'
        doc.render :pdf, :filename => nomDuFichier
        #-------------

end

IO.foreach("tst.txt") { |block|

        ligneFichier = block.split(' ; ')
                creeCodeBarre(ligneFichier)

}

Thanks for your help.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
zzzer  
View profile
 More options 9 Jul, 12:48
From: zzzer <f...@free.fr>
Date: Wed, 9 Jul 2008 04:48:56 -0700 (PDT)
Local: Wed 9 Jul 2008 12:48
Subject: Re: Another encoding problem
I don't konw if it's good, but as the problem was from c:/ruby/lib/
ruby/gems/1.8/gems/rghost-0.8/lib/rghost/
ruby_ghost_config.rb , I opened this file, and, at line 67, modified
the line

:charset_convert => lambda {|text| Iconv::iconv('latin1','utf8',
text) }
to
:charset_convert => lambda {|text| Iconv::iconv('latin1','latin1',
text) }

And now, the errors it shows are :

C:\Documents and Settings\Administrateur\Bureau>ruby zcb.rb
c:/ruby/lib/ruby/gems/1.8/gems/rghost-0.8/lib/rghost/
ruby_ghost_engine.rb:84:in `initialize': No such file or directory -
10987654321.Docteur.pdf.rgerr (Errno::ENOENT)
        from c:/ruby/lib/ruby/gems/1.8/gems/rghost-0.8/lib/rghost/
ruby_ghost_engine.rb:84:in `open'
        from c:/ruby/lib/ruby/gems/1.8/gems/rghost-0.8/lib/rghost/
ruby_ghost_engine.rb:84:in `render'
        from c:/ruby/lib/ruby/gems/1.8/gems/rghost-0.8/lib/rghost/
document.rb:197:in `render'
        from zcb.rb:136:in `creeCodeBarre'
        from zcb.rb:146
        from zcb.rb:142:in `foreach'
        from zcb.rb:142

But ruby_ghost_engine.rb seems more complicated, so I don't want to
modify it...

Does someone know what to do ?


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Shairon Toledo  
View profile
 More options 9 Jul, 19:01
From: "Shairon Toledo" <shairon.tol...@gmail.com>
Date: Wed, 9 Jul 2008 15:01:46 -0300
Local: Wed 9 Jul 2008 19:01
Subject: Re: [postscriptbarcode] Re: Another encoding problem

You can disable the charset_convert using

RGhost::Config[:charset_convert]=nil

writer in directory.

For more details enable the log file

doc.render :pdf, :filename => "foo.pdf", :debug => true, :logfile =>
"rghost_log.txt"

> But ruby_ghost_engine.rb seems more complicated, so I don't want to
> modify it...

> Does someone know what to do ?

--
[ ]'s
Shairon Toledo
http://www.hashcode.eti.br

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
zzzer  
View profile
 More options 9 Jul, 22:52
From: zzzer <f...@free.fr>
Date: Wed, 9 Jul 2008 14:52:55 -0700 (PDT)
Local: Wed 9 Jul 2008 22:52
Subject: Re: Another encoding problem

On 9 juil, 20:01, "Shairon Toledo" <shairon.tol...@gmail.com> wrote:

> You can disable the charset_convert using

> RGhost::Config[:charset_convert]=nil

This instruction isn't recognized...

And I tried a really simple Ruby program :

require 'rubygems'
require 'rghost'
require 'rghost_barcode'
include RGhost

doc=Document.new

doc.render :pdf, :filename => "foo.pdf", :debug => true, :logfile =>
"rghost_log.txt"

But it doesn't work on Windows !
Here's the error :

C:/ruby/lib/ruby/gems/1.8/gems/gems/rghost-0.8.1/lib/rghost/
ruby_ghost_engine.rb:84:in 'initialize': No such file or directory -
foo.pdf.rgerr (Errno::ENOENT)

Is RGhost fully compatible with Windows ?
Or is my installation incomplete (Ruby + RGhost + Rghost_barcode) ?


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Shairon Toledo  
View profile
 More options 10 Jul, 00:18
From: "Shairon Toledo" <shairon.tol...@gmail.com>
Date: Wed, 9 Jul 2008 20:18:28 -0300
Local: Thurs 10 Jul 2008 00:18
Subject: Re: [postscriptbarcode] Re: Another encoding problem

Again, try change your temp dir using

RGhost::Config::GS[:tmpdir]="C:\\mydir\\writable

Is RGhost fully compatible with Windows ?

Yes!

Or is my installation incomplete (Ruby + RGhost + Rghost_barcode) ?

No. It's complete.

--
[ ]'s
Shairon Toledo
http://www.hashcode.eti.br

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
zzzer  
View profile
 More options 10 Jul, 08:08
From: zzzer <f...@free.fr>
Date: Thu, 10 Jul 2008 00:08:19 -0700 (PDT)
Local: Thurs 10 Jul 2008 08:08
Subject: Re: Another encoding problem

> Again, try change your temp dir using

> RGhost::Config::GS[:tmpdir]="C:\\mydir\\writable

I did it (with "C:\toto"), but the error is still :

c:/ruby/lib/ruby/gems/1.8/gems/rghost-0.8/lib/rghost/
ruby_ghost_engine.rb:84:in `initialize': No such file or directory -
10987654321.Docteur.pdf.rgerr (Errno::ENOENT)

=(


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Shairon Toledo  
View profile
 More options 10 Jul, 12:26
From: "Shairon Toledo" <shairon.tol...@gmail.com>
Date: Thu, 10 Jul 2008 08:26:21 -0300
Local: Thurs 10 Jul 2008 12:26
Subject: Re: [postscriptbarcode] Re: Another encoding problem

Try the simple code below

File.open("C:\\your\\temp\\path\\file.txt", "w"){|f| f.puts "something" }

The rghost works this simple way.

On Thu, Jul 10, 2008 at 4:50 AM, zzzer <f...@free.fr> wrote:

> Sorry for the flood >_<

--
[ ]'s
Shairon Toledo
http://www.hashcode.eti.br

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
zzzer  
View profile
 More options 10 Jul, 13:01
From: zzzer <f...@free.fr>
Date: Thu, 10 Jul 2008 05:01:48 -0700 (PDT)
Local: Thurs 10 Jul 2008 13:01
Subject: Re: Another encoding problem

> Try the simple code below

> File.open("C:\\your\\temp\\path\\file.txt", "w"){|f| f.puts "something" }

> The rghost works this simple way.

Yes, it works...

But it doesn't resolve my problem with my Ruby problem :s
I still have this error :

c:/ruby/lib/ruby/gems/1.8/gems/rghost-0.8/lib/rghost/
ruby_ghost_engine.rb:84:in `initialize': No such file or directory -
10987654321.Docteur.pdf.rgerr (Errno::ENOENT)


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Shairon Toledo  
View profile
 More options 10 Jul, 13:22
From: "Shairon Toledo" <shairon.tol...@gmail.com>
Date: Thu, 10 Jul 2008 09:22:41 -0300
Local: Thurs 10 Jul 2008 13:22
Subject: Re: [postscriptbarcode] Re: Another encoding problem

More two tests
On your windows this line works?

 RGhost::Config.is_ok?.render :pdf, :filename => "c:\\your\path\\ok.pdf"

another send me the content of the your document, example

doc=RGhost::Document.new
doc....
doc....
doc....
doc.done
File.open("C:\\file.ps"){|f| f.puts doc.ps }

I'm waiting.

--
[ ]'s
Shairon Toledo
http://www.hashcode.eti.br

--
[ ]'s
Shairon Toledo
http://www.hashcode.eti.br

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
zzzer  
View profile
 More options 10 Jul, 13:38
From: zzzer <f...@free.fr>
Date: Thu, 10 Jul 2008 05:38:09 -0700 (PDT)
Local: Thurs 10 Jul 2008 13:38
Subject: Re: Another encoding problem

> On your windows this line works?

>  RGhost::Config.is_ok?.render :pdf, :filename => "c:\\your\path\\ok.pdf"

No, this simple line doesn't work...
Always the same error... :

C:\Documents and Settings\Administrateur\Bureau>ruby toto.rb
c:/ruby/lib/ruby/gems/1.8/gems/rghost-0.8/lib/rghost/
ruby_ghost_engine.rb:84:in `initialize': No such file or directory -
ok.pdf.rgerr (Errno::ENOENT)
        from c:/ruby/lib/ruby/gems/1.8/gems/rghost-0.8/lib/rghost/
ruby_ghost_engine.rb:84:in `open'
        from c:/ruby/lib/ruby/gems/1.8/gems/rghost-0.8/lib/rghost/
ruby_ghost_engine.rb:84:in `render'
        from c:/ruby/lib/ruby/gems/1.8/gems/rghost-0.8/lib/rghost/
document.rb:197:in `render'
        from toto.rb:13

Here is the program I've executed to have this :

require 'rubygems'
require 'rghost'
require 'rghost_barcode'
include RGhost

RGhost::Config.is_ok?.render :pdf, :filename => "ok.pdf"


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Shairon Toledo  
View profile
 More options 10 Jul, 14:04
From: "Shairon Toledo" <shairon.tol...@gmail.com>
Date: Thu, 10 Jul 2008 10:04:22 -0300
Local: Thurs 10 Jul 2008 14:04