Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 19th, 2013, 04:56 PM
dokhebi dokhebi is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2011
Posts: 23 dokhebi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 17 m 50 sec
Reputation Power: 0
Strangeness in PostScript::Simple

I'm storing a string in a database with non-ASCII characters encoded in hex (trademark, \xd4). I want to pass this string on to PostScript::Simple in the text method to build a file that will be converted to PDF. When it comes out of the database there is only on \ and, according to the code in the module if it starts with \x and has two valid hex digits it's supposed to be converted to octal. But instead the \ is escaped with another \ and my PDF now has \xd4 instead of the trade mark symbol. I copied the substitution code:
Code:
$text =~ s|([\\\(\)])|\\$1|g;
$text =~ s/([\x00-\x1f\x7f-\xff])/sprintf('\\%03o',ord($1))/ge;

out of the module and put it in a separate file and it works, \xd4 is converted to \324 as expected.

Any idea what's going on?

I'm using Perl v5.14.2 and PostScript::Simple v0.07 under Cygwin on WinXP Pro.

Reply With Quote
  #2  
Old February 20th, 2013, 04:52 AM
ishnid's Avatar
ishnid ishnid is offline
kill 9, $$;
Dev Shed God 4th Plane (6500 - 6999 posts)
 
Join Date: Sep 2001
Location: Shanghai, An tSín
Posts: 6,894 ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level) 
Time spent in forums: 4 Months 2 Weeks 1 Day 22 h 14 m 53 sec
Reputation Power: 3885
Can you post a sample of the text you're trying to process also?

Reply With Quote
  #3  
Old February 20th, 2013, 10:44 AM
dokhebi dokhebi is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2011
Posts: 23 dokhebi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 17 m 50 sec
Reputation Power: 0
Some example code:

Code:
#!/usr/bin/perl -w
use strict;

my $text = "Fuzzie Slippers\xd4 are great!";
$text =~ s|([\\\(\)])|\\$1|g;
$text =~ s/([\x00-\x1f\x7f-\xff])/sprintf('\\%03o',ord($1))/ge;
print "$text\n";

and the output is:

Code:
Fuzzie Slippers\324 are great!

how ever, if I use the PostScript::Simple text method:

Code:
$p->text({align => center}, 4.25, 5.5, $text);

the line in the PostScript file would look like this:

Code:
(Fuzzie Slippers\\xd4 are great!)   dup stringwidth pop 2 div neg 0 rmoveto show

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Strangeness in PostScript::Simple

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap