Debian :: Perl Script - Converting Unicode To ASCII?

May 7, 2010

I'm trying to write a Perl script that will convert text to ASCII. I'm particularly interested in converting files created with MS Windows, so I used Notepad to create a few test files.

I have had some success with the following script:
[[ Script Deleted -- see subsequent posts ]]

After coming back /home/ to Debian, I used file to examine the file types:
$ file ansi.txt unicode_big-endian.txt unicode.txt utf8.txt
ansi.txt: ASCII text, with CRLF line terminators
unicode_big-endian.txt: Big-endian UTF-16 Unicode character data, with CRLF line terminators
unicode.txt: Little-endian UTF-16 Unicode character data, with CRLF, CR line terminators
utf8.txt: UTF-8 Unicode (with BOM) text, with CRLF line terminators

After running:
$ uni2ascii.pl -i ansi.txt -c ASCII -o new_ansi.txt
$ uni2ascii.pl -i unicode_big-endian.txt -c utf16 -o new_unicode_big-endian.txt
$ uni2ascii.pl -i unicode.txt -c utf16 -o new_unicode.txt
$ uni2ascii.pl -i utf8.txt -c utf8 -o new_utf8.txt

Everything appears good:
$ file new_ansi.txt new_unicode_big-endian.txt new_unicode.txt new_utf8.txt
new_ansi.txt: ASCII text
new_unicode_big-endian.txt: ASCII text
new_unicode.txt: ASCII text
new_utf8.txt:ASCII text

But the "little-endian file" does not convert properly:
$ md5sum new_ansi.txt new_unicode_big-endian.txt new_unicode.txt new_utf8.txt
c4def7932bc151b9e786b6ca1299162c new_ansi.txt
c4def7932bc151b9e786b6ca1299162c new_unicode_big-endian.txt
5b62a013dced4f2c2c0af45ea6388c1e new_unicode.txt
c4def7932bc151b9e786b6ca1299162c new_utf8.txt

When I use cat to print the new_unicode.txt file in an Emacs terminal, a ^@ appears on the last (empty) line. When I open the new_unicode.txt with KWrite, a warning message tells me that the file is a "binary" and "saving it will result in a corrupt file."

View 14 Replies


ADVERTISEMENT

Red Hat :: Convert A Unicode File To Ascii?

Jul 1, 2010

I need to be able to convert a unicode file to ascii using red hat.

View 1 Replies View Related

Programming :: Checking Function - Character ASCII Or Unicode

Jan 20, 2009

To know the function on checking whether a character is ascii or unicode character. From the following [uRL]. The function IsTextUnicode is related to Windows VC++ library. I would like to know the library/function which provides such facility.

View 2 Replies View Related

Programming :: Convert Multiple File In Directory - Ascii To Hex In Perl ?

Apr 9, 2011

I have found a perl script that can convert single file: ascii to hex.

However I have thousand of file that I want to convert from ascii to hex.

Here is the perl script that convert single ascii file to hex in single line:

Quote:

So I would like to read multiple file from a directory.

Then the file will be have same name file with hex data.

Here is sample of the read and write directory file.

Quote:

View 3 Replies View Related

Programming :: Converting MB/TB To GB In Perl?

Jan 30, 2010

I am taking an input from the user for free and Used capacity in a disk. I wish to convert Input entered in MBTB to GB and this is how i am doing it.

Code:

<some code>
print "Enter Total disk space";
$tot = <STDIN>;
convert($tot);

[code]...

how do i pass the value of conv[0] after conversion back to $tot or $use such that they contain only value which is in GB?

View 3 Replies View Related

Programming :: Perl Compilation Error "Cannot Locate Unicode/String.pm In @INC"

Mar 9, 2010

I get an error when typing perl build.pl: Code: Cannot locate Unicode/String.pm in @INC

View 11 Replies View Related

Programming :: Converting Perl Script To Python?

Jul 21, 2011

#!/usr/bin/perl
print "Input File Name: ";
$filename = <>;
$filename =~ s/s+$//;mkdir "$filename";

[code]....

View 3 Replies View Related

Debian :: Launch The Perl Config \ Seems To Be That It Does Not Regonize Perl?

Jul 7, 2010

I am trying to launch the perl config, but when I do so I can an weird error.It seems to be that it does not regonize perl ?

conf.pl: line 11: =: command not found
conf.pl: line 19: my: command not found
conf.pl: line 20: syntax error near unexpected token `{'

[code]...

View 2 Replies View Related

Debian :: Rxvt-unicode And Vim Insert Mode

Jan 12, 2016

When entering insert mode in a text file i want to edit while using rxvt-unicode, there is a p being inserted and a whole new line is entered as well. when i hit the insert key, vim enters insert mode but also types a p and forces whatever line i am on down a line. if num lock is not on, it will not enter insert mode by pressing the insert key but if i type using the keyboard and not the number pad, it still enters text. vim/mode keys work normally in xterm. is there some unusual configuration required in order to get vim to behave properly within rxvt-unicode?

created ~/.Xmodmap file as outlined here: [URL] ....

View 0 Replies View Related

Debian Multimedia :: Install Font With Better Unicode Support?

Mar 20, 2015

I'm running a Debian Wheezy system. There are a lot of characters I want to use from the U+1F*** set of characters. But when I use them or look them up in the character map, all I see is the square with the code inside. Is there some font package I can install from the repository that has better support for these characters?

E.g., when I am instant messaging my girlfriend, I like to use the HEAVY BLACK HEART character (❤, U+2764). But there are a whole bunch of other "romantic" characters that are listed but not actually displaying for me, like the KISS MARK (U+1F48B), which I would like to use. These characters apparently show up on her system, which is an android phone.

View 8 Replies View Related

Debian :: Getting Unicode Characters (Japanese) To Display Properly?

Mar 3, 2009

I recently intalled Debian lenny and I'm having issues with some of the unicode characters. Instead of displaying the symbols properly it shows one of the following depending on font/app:

1) Square outline with four letters/numbers arranged inside
2) Just a blank square outline
3) Just a blank space

I haven't been able to test all possible characters, but from a quick check it seems that Cyrillic works properly, Japanese doesn't.A few Google searches later and I'm no wiser on how to fix the issue. Any help?

View 2 Replies View Related

CentOS 5 :: Convert Between "ASCII English Text" And "ASCII Text"?

Aug 3, 2011

This is weird, and I never noticed before, but now I have an application that is borking on weird things like when /etc/hosts is of one file format or another, and I don't even know the difference between the two (google doesn't tell much either). on CentOS 5.5/5.6 x86_64: a which on the following is an interesting tell:

vi = /bin/vi
vim = /usr/bin/vim

both are actually vim version 7.0.237 but sum differently, and although they are both actually separate executables in the stock installs of CentOS I've been building, on most distros, and older versions of CentOS it seems, vi is usually just a symlink to vim - but again, not in these fresh installs it seems. When I create a file with the 'vi' above, it defaults (usually) to "ASCII text" (but not always) When I create a file with the 'vim' above, it defaults to "ASCII English text" (and causes a particular application I'm working with to bork and barf). It seems the OS is installed by default yielding both file types too, as evidenced by the following:

[Code]...

View 4 Replies View Related

Debian :: Xorg Crash After Converting / Partition To LVM?

Oct 6, 2010

I have Virtualbox VM with Lenny and I made another hdd copying all files from old drive to new one. But root partition I made to be on LVM and all three partitions are now primary. After using Debian DVD and rescue mode to reinstall grub and reconfigure kernel, the system boots fine, but Xorg fails to start.

Code:
Backtrace:
0: /usr/bin/X11/X(xf86SigHandler+0x7e) [0x80c91ce]
1: [0xb776d400]
2: /usr/bin/X11/X(xf86PostMotionEventP+0x97) [0x80e71e7]

[Code]...

View 1 Replies View Related

Debian Configuration :: Converting From Desktop / GUI To Headless Server

Mar 25, 2016

I set up my Debian box as a HTPC but am moving it to my closet and using it as a NAS now, so I want to make it headless since there won't be a monitor connected to it.What's the cleanest way to nuke the desktop environment? 2nd to reinstalling, that is (although that may not be a bad option since may home directory is in another partition).

View 1 Replies View Related

CentOS 5 Server :: Move 5.5 To /usr/bin/perl So Root Based On Perl 5.12.1?

Aug 11, 2010

I am new here and want to lern CentOS. Current I have installed CentOS 5.5 x64 and Perl 5.8.8. Now i have install Perl 5.12.1 which located to /usr/local/bin/perl. But how I can move it to /usr/bin/perl so root based on Perl 5.12.1?

View 7 Replies View Related

Ubuntu :: Switch Back To /usr/bin/perl After Installing Second Perl?

Aug 14, 2010

I recently reinstalled the B module for perl. Now I found out it didn't just do that, it installed a whole new copy of perl into /usr/local/bin/perl. When I type 'which perl' at the terminal, it says '/usr/local/bin/perl' instead of '/usr/bin/perl'. Normally, this wouldn't bother me. But I installed the one in local/bin without threading support. The one that comes with the system already is build with threading support, which is why I want to switch back to the system perl, and possibly remove the one in /usr/local/bin.

So how do I change it so that the result of 'which perl' returns as '/usr/bin/perl'? And what do I have to do to remove /usr/local/bin/perl?

The reason I need threading support is because I'm designing a file copier that copies several chunks of a file simultaneously to speed up the copying process. Guaranteed a useful script if it works.

View 7 Replies View Related

OpenSUSE :: Difference Between Perl And Perl-devel?

Jun 28, 2010

I'm new in perl programming and linux OS. What is the difference between perl and perl-devel? What does mean devel? Iwant to install Catalyst and before install as required I have to check if make, gcc and perl-devel are installed in my system. make and gcc are installed. But I have to install perl-devel. First I searched for make, gcc and perl-devel in YAST Software Management and search did not find perl-devel. I visited the software.opensuse.org and wrote "perl-devel" and searched. The result was many similar zips with a prefix perl-devel and I can not choose one for needed perl-devel.

[Code]...

View 5 Replies View Related

Debian :: E - Can't Perform Immediate Configuration On 'perl'?

Aug 24, 2011

I'm getting the following error when I'm trying to install from 'testing' repo. E: Could not perform immediate configuration on 'perl' I'm doing apt pinning to install XFCE 4.8 on Squeeze. I've already added all the necessary sources and my /etc/apt/preferences file looks like this.

Package: *
Pin: release a=testing
Pin-Priority: 400
Package: *
Pin: release a=unstable
Pin-Priority: 300
Here is what I'm trying to install.

apt-get -t testing install xfce4 xfdesktop4 xfce4-power-manager xfce4-screenshooter xfce4-notifyd thunar thunar-archive-plugin thunar-media-tags-plugin thunar-thumbnailers gvfs-backends gvfs-bin gvfs-fuse xfce4-mixer xfburn terminator

View 1 Replies View Related

Debian :: Could Not Perform Immediate Configuration On 'perl'?

Aug 27, 2011

I am on a friend's box and we are atm transitioning from stable to sid on his box. Instead of doing the whole thing at one shot via update-manager we are doing it using the apt tools. Now while upgrading, I'm not able to update any of the perl 5.12 packages, perhaps due to circular dependencies or what. This is the error I'm seeing :-

$ sudo apt-get install perl
[sudo] password for shirish:
Reading package lists... Done

[code]....

View 2 Replies View Related

Debian :: Build A .deb File Which Will Contain Perl Program?

Aug 18, 2010

I'd like to build a .deb file which will contain my Perl program. I just want it to be deployed with dpkg -i on debian systems later. So it's just a matter of having the good arborescence in my .deb package. For that purpose, in the debian/rules file, I'm declaring some dh_install lines in the install rule.

My issue is that I know how to achieve my goal, but only with writing a ton of dh_install lines (one line, for one file...)

example :
clean:
dh_testdir
dh_clean
install: build

[Code].....

View 4 Replies View Related

Debian :: Install Perl Modules Using CPAN?

Mar 5, 2010

Can anyone provide me information about installing perl modules using CPAN.....

View 1 Replies View Related

Programming :: How To Get A Unicode Number

Jul 7, 2011

But what is the easiest way to figure out the Unicode number of a character when you already have the character?

For instance, I pasted this character here from a PDF:

View 4 Replies View Related

Software :: How Do New Unicode Characters Get Implemented?

Apr 17, 2009

From time to time, new characters are added to the unicode standard.For instance, in 2008 a capital sharp s (upper case form of German eszett)was added at position 0x1e9e.What actions need to be taken in order to make the new character part of the various fonts we use on our desktops?

View 1 Replies View Related

Programming :: Displaying Unicode Characters

Feb 19, 2011

I wrote a java program that writes strings to a file. The strings contain foreign language characters. When I run the program in Windows, the output file shows the foreign characters. However, when I attempt the same operation in Linux, the output file shows a white question mark in a black background instead of the foreign characters. The same Linux system could display the foreign characters if I copy the output file from Windows to Linux. I tried to create the output file using gedit that my program would then add additional strings to and chose Unicode-32 for encoding but still the same problem.

What could I do to get the program to display the foreign language characters from output text file?

View 6 Replies View Related

Programming :: How Renders Unicode Characters?

Oct 13, 2009

I am working on an application that will convert English text into equivalent Indian language text. Since Unicode is the standard, I will be using it. In most of the western languages each code-value directly refers to the glyph index and placing the code-values side by side will give the required display. This one to one mapping is not possible in Indian languages where rendering syllables is required rather than rendering just consonants and vowels. Many of the complex characters are made up by combining several unicode values.

My question here is: How Linux renders this Unicode text correctly? More specifically, what package is used? I believe in Windows they use Uniscribe for rendering.I believe there will be an operating system library for handling the text rendering. Or do I need to write my own rendering engine? How programs like Firefox, GEdit shows unicode text? Do they also have proprietary engines for correct rendering?

View 2 Replies View Related

Programming :: Printing Unicode Characters In C

Sep 5, 2009

Say I want to write some of the more exotic Unicode characters to a file, what's the proper way to do it? when decimal integers are involved, we use %d for floating point we use %f and for hex we use %p.What's the equivalent marker for Unicode values that C understands?

View 3 Replies View Related

Debian Programming :: Using Perl To Replace Filename Strings In A Directory

Jun 12, 2013

I have a directory of orchestral music .ogg files from a family member. Each track is from a different artist and the CDDB entry adds a ":" character after the artist name in the track title.

Here is an example of what I am referring to:

Code: Select all13_-_Mozart:_Sonata_in_A_major_KV_331.ogg

I would like to parse file names in any given directory and search for the string Code: Select all: and replace it with Code: Select all_ According to this post on stackoverflow, I can use Perl to accomplish this task. I've tried Code: Select allperl -i.bak -pe 's/:/_/' but since I am still learning Perl I'm probably commiting a PEBKAC error.

How would I go about solving this issue with regular expressions using Perl?

View 3 Replies View Related

Ubuntu :: Restricted To Debian Versions Of Things Like Perl, MySQL?

Dec 13, 2010

As I mentioned on another thread, I have 2 Ubuntus - Jaunty and Meerkat - as separate drives on my secondary IDE channel. I am removing Jaunty. Meerkat blows it away. And is certainly my preferred OS. However I am looking for a replacement for Jaunty that is more flexible in certain key areas than Ubuntu appears to be.I dont want to be restricted to Debian versions of things like Perl, MySQL, PHP and others. I can run LAMPP, but I would prefer to compile and have the versions of my choice as part of a main test system (apart from Meerkat that is).

I have had enough nightmares in Jaunty with things getting broken and spiralling out of control. I want a distro that doesnt rely on the GUI and its attendant utilities, but can run them when called. Meerkat is stable and has resisted me breaking it so far, but I do not want to push my luck. I have too much time invested in it. I intend to use Meerkat as my primary system on the machine, but want an alternative to *PLAY* with.

View 9 Replies View Related

Fedora :: Extended Characters (Unicode Numbers) In F12

Dec 9, 2009

In previous versions of Fedora I was able to do Ctrl + Shift + U, enter the Unicode number - i.e., 20ac, press Enter and get a euro character. In Fedora 12 I do not have that feature. My language is US English.

View 5 Replies View Related

OpenSUSE :: Nautilus Not Displaying Unicode Characters

May 6, 2010

I'm using openSUSE 11.2 with GNOME dual-booted with Windows 7, been installed from scratch for like a week. The bottom line is: Nautilus displays a series of matrices, "x"s and other symbols instead of characters in Hebrew.

Screenshot:

Now, it worked fine at the beginning but once I started installing updates it went. I installed a whole bunch of updates and programs so I don't know what changed it. The weird part is (as you can see in the screenshot) that the shortcut to the left of a Hebrew-named folder shows up correctly only the first time Nautilus opens after starting. So as soon as I closed the Nautilus window after taking the screenshot and reopened it, it also displayed like the others. The screenshot is of my ntfs Windows drive, however the problem occurs in my home folder as well.

Here's my fstab anyway:

Code:
/dev/disk/by-id/ata-ST9160821AS_5MA727CM-part5 swap swap defaults 0 0
/dev/disk/by-id/ata-ST9160821AS_5MA727CM-part6 / ext4 acl,user_xattr 1 1

[Code]....

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved