12-07-2012
Hello,
I found the problem. BOM: Byte Order mark
Normally under windows a UTF-8 file starts with a BOM (byte order mark, U+FEFF), as is standard for UTF-8 files on Windows systems. I concede that it is legal for them to do so, but it is utterly pointless since the byte order is determined by the formal specification of the UTF-8 representation itself. And it just happens that, unlike the rest of UTF-8, an initial BOM will screw up a Unix system. And Perl is supposed to be
Quote:
"an oasis of Unix culture in the desert of can't-get-there-from here" (Larry Wall, probably slightly misquoted).
Using a hex editor I removed the FEFF and it worked like a charm.
On Linux you should have no problem, since this aberration does not exist ina Unix system
Many thanks for trying to solve the mystery.
As an aid to all of us who suffer the tyranny of the WinOS system, here is a useful link:
HTML Code:
http://www.perlmonks.org/?node_id=599720.
This offers two solutions for the problem. Googling
Quote:
"perl bom" or "perl File::BOM"
comes up with more if needed.
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
Hi - I tried to remove ^M in a delimited file using "tr -d "\r" and "sed 's/^M//g'", but it does not work quite well. While the ^M is removed, the format of the record is still cut in half, like
a,b, c
c,d,e
The delimited file is generated using sh script by outputing a SQL query result to... (7 Replies)
Discussion started by: sirahc
7 Replies
2. Shell Programming and Scripting
Hi Experts
I am very new to perl and need to make a script using perl.
I would like to remove blanks in a text tab delimited file in in a specfic column range ( colum 21 to column 43) sample input and output shown below :
Input:
117 102 650 652 654 656
117 93 95... (3 Replies)
Discussion started by: Faisal Riaz
3 Replies
3. Shell Programming and Scripting
Hey there - a bit of background on what I'm trying to accomplish, first off. I am trying to load the data from a pipe delimited file into a database. The loading tool that I use cannot handle embedded newline characters within a field, so I need to scrub them out.
Solutions that I have tried... (7 Replies)
Discussion started by: bbetteridge
7 Replies
4. Shell Programming and Scripting
I have a large flat file with variable length fields that are pipe delimited. The file has no new line or CR/LF characters to indicate a new record. I need to parse the file and after some number of fields, I need to insert a CR/LF to start the next record.
Input file ... (2 Replies)
Discussion started by: clintrpeterson
2 Replies
5. Shell Programming and Scripting
Hi All
I wanted to know how to effectively delete some columns in a large tab delimited file.
I have a file that contains 5 columns and almost 100,000 rows
3456 f g t t
3456 g h
456 f h
4567 f g h z
345 f g
567 h j k lThis is a very large data file and tab delimited.
I need... (2 Replies)
Discussion started by: Lucky Ali
2 Replies
6. Shell Programming and Scripting
Since there are approximately 75K gsfiles and hundreds of stfiles per gsfile, this script can take hours. How can I rewrite this script, so that it's much faster? I'm not as familiar with perl but I'm open to all suggestions.
ls file.list>$split
for gsfile in `cat $split`;
do
csplit... (17 Replies)
Discussion started by: verge
17 Replies
7. Shell Programming and Scripting
Hi,
I have the following command in place
nawk -F, '!a++' file > file.uniq
It has been working perfectly as per requirements, by removing duplicates by taking into consideration only first 3 fields. Recently it has started giving below error:
bash-3.2$ nawk -F, '!a++'... (17 Replies)
Discussion started by: makn
17 Replies
8. Shell Programming and Scripting
I am working on a homonym dictionary of names i.e. names which are clustered together according to their “sound-alike” pronunciation:
An example will make this clear:
Since the dictionary is manually constructed it often happens that inadvertently two sets of “homonyms” which should be grouped... (2 Replies)
Discussion started by: gimley
2 Replies
9. UNIX for Advanced & Expert Users
I have a file size is around 24 G with 14 columns, delimiter with "|"
My requirement- can anyone provide me the fastest and best to get the below results
Number of records of the file
First column and second Column- Unique counts
Thanks for your time
Karti
------ Post updated at... (3 Replies)
Discussion started by: kartikirans
3 Replies
10. Shell Programming and Scripting
I have a large file 1.5 gb and want to sort the file.
I used the following AWK script to do the job
!x++
The script works but it is very slow and takes over an hour to do the job. I suspect this is because the file is not sorted.
Any solution to speed up the AWk script or a Perl script would... (4 Replies)
Discussion started by: gimley
4 Replies
LEARN ABOUT OPENSOLARIS
uconv_u8tou16
uconv_u16tou32(3C) Standard C Library Functions uconv_u16tou32(3C)
NAME
uconv_u16tou32, uconv_u16tou8, uconv_u32tou16, uconv_u32tou8, uconv_u8tou16, uconv_u8tou32 - Unicode encoding conversion functions
SYNOPSIS
#include <sys/types.h>
#include <sys/errno.h>
#include <sys/u8_textprep.h>
int uconv_u16tou32(const uint16_t *utf16str, size_t *utf16len,
uint32_t *utf32str, size_t *utf32len, int flag);
int uconv_u16tou8(const uint16_t *utf16str, size_t *utf16len,
uchar_t *utf8str, size_t *utf8len, int flag);
int uconv_u32tou16(const uint32_t *utf32str, size_t *utf32len,
uint16_t *utf16str, size_t *utf16len, int flag);
int uconv_u32tou8(const uint32_t *utf32str, size_t *utf32len,
uchar_t *utf8str, size_t *utf8len, int flag);
int uconv_u8tou16(const uchar_t *utf8str, size_t *utf8len,
uint16_t *utf16str, size_t *utf16len, int flag);
int uconv_u8tou32(const uchar_t *utf8str, size_t *utf8len,
uint32_t *utf32str, size_t *utf32len, int flag);
PARAMETERS
utf16str A pointer to a UTF-16 character string.
utf16len As an input parameter, the number of 16-bit unsigned integers in utf16str as UTF-16 characters to be converted or saved.
As an output parameter, the number of 16-bit unsigned integers in utf16str consumed or saved during conversion.
utf32str A pointer to a UTF-32 character string.
utf32len As an input parameter, the number of 32-bit unsigned integers in utf32str as UTF-32 characters to be converted or saved.
As an output parameter, the number of 32-bit unsigned integers in utf32str consumed or saved during conversion.
utf8str A pointer to a UTF-8 character string.
utf8len As an input parameter, the number of bytes in utf8str as UTF-8 characters to be converted or saved.
As an output parameter, the number of bytes in utf8str consumed or saved during conversion.
flag The possible conversion options that are constructed by a bitwise-inclusive-OR of the following values:
UCONV_IN_BIG_ENDIAN
The input parameter is in big endian byte ordering.
UCONV_OUT_BIG_ENDIAN
The output parameter should be in big endian byte ordering.
UCONV_IN_SYSTEM_ENDIAN
The input parameter is in the default byte ordering of the current system.
UCONV_OUT_SYSTEM_ENDIAN
The output parameter should be in the default byte ordering of the current system.
UCONV_IN_LITTLE_ENDIAN
The input parameter is in little endian byte ordering.
UCONV_OUT_LITTLE_ENDIAN
The output parameter should be in little endian byte ordering.
UCONV_IGNORE_NULL
The null or U+0000 character should not stop the conversion.
UCONV_IN_ACCEPT_BOM
If the Byte Order Mark (BOM, U+FEFF) character exists as the first character of the input parameter, interpret it as the
BOM character.
UCONV_OUT_EMIT_BOM
Start the output parameter with Byte Order Mark (BOM, U+FEFF) character to indicate the byte ordering if the output parame-
ter is in UTF-16 or UTF-32.
DESCRIPTION
The uconv_u16tou32() function reads the given utf16str in UTF-16 until U+0000 (zero) in utf16str is encountered as a character or until the
number of 16-bit unsigned integers specified in utf16len is read. The UTF-16 characters that are read are converted into UTF-32 and the
result is saved at utf32str. After the successful conversion, utf32len contains the number of 32-bit unsigned integers saved at utf32str as
UTF-32 characters.
The uconv_u16tou8() function reads the given utf16str in UTF-16 until U+0000 (zero) in utf16str is encountered as a character or until the
number of 16-bit unsigned integers specified in utf16len is read. The UTF-16 characters that are read are converted into UTF-8 and the
result is saved at utf8str. After the successful conversion, utf8len contains the number of bytes saved at utf8str as UTF-8 characters.
The uconv_u32tou16() function reads the given utf32str in UTF-32 until U+0000 (zero) in utf32str is encountered as a character or until the
number of 32-bit unsigned integers specified in utf32len is read. The UTF-32 characters that are read are converted into UTF-16 and the
result is saved at utf16str. After the successful conversion, utf16len contains the number of 16-bit unsigned integers saved at utf16str as
UTF-16 characters.
The uconv_u32tou8() function reads the given utf32str in UTF-32 until U+0000 (zero) in utf32str is encountered as a character or until the
number of 32-bit unsigned integers specified in utf32len is read. The UTF-32 characters that are read are converted into UTF-8 and the
result is saved at utf8str. After the successful conversion, utf8len contains the number of bytes saved at utf8str as UTF-8 characters.
The uconv_u8tou16() function reads the given utf8str in UTF-8 until the null ('