Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Spaces are being added between all characters

Status
Not open for further replies.

GreazyMcgeezy

Technical User
Jun 10, 2012
2
0
0
US
I'm looking for assistance with an issue I'm having on this log file. Basically all I'm trying to do is open a file and save it into an array for searching. On a small test.txt file that I created with a few lines, it does this no problem and prints elements of the array without issues. I have a log file that is much larger that I wanted to use for testing and practice, but every time I load it into the array the same way as the sample text file, for some reason it gets a space added between every character. Can you point me in the right direction of why?

Perl:
use feature ':5.10';

my $file = <STDIN>;

open (FH, $file);
my @raw = <FH>;
close (FH);

print $raw[0];

Here is the original line in the file:
Code:
=== Verbose logging started: 5/1/2012  3:00:40  Build type: SHIP UNICODE 3.01.4001.5512  Calling process: c:\96a3e4c72f1c1c4b5d35fb9c55a993\x86\Setup.exe ===

Here is the output once it's been loaded to the array and printed as $raw[0]:
Code:
 ■= = =   V e r b o s e   l o g g i n g   s t a r t e d :   5 / 1 / 2 0 1 2
3 : 0 0 : 4 0     B u i l d   t y p e :   S H I P   U N I C O D E   3 . 0 1 . 4
0 0 1 . 5 5 1 2     C a l l i n g   p r o c e s s :   c : \ 9 6 a 3 e 4 c 7 2 f
c 1 c 4 b 5 d 3 5 f b 9 c 5 5 a 9 9 3 \ x 8 6 \ S e t u p . e x e   = = =

As you can see, there is an additional space between EVERY character... I have no clue why. It also appears in the command window like every character is in it's unique column. So looking back through the code everything lines up so that all visible characters are in the same lines. The 'spaced columns' have no characters in them.

Thanks in advance!
 
Ok, nevermind. I figured out what my problem was.

The file had been saved as a ANSI when it contained Unicode characters. Resaved the file as UTF-8 Encoding and resolved my issue.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top