The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
replacing characters infyanurag Shell Programming and Scripting 3 05-21-2008 01:55 AM
replacing characters palmer18 UNIX for Dummies Questions & Answers 3 08-20-2007 09:58 AM
problem with Unicode characters insertion suman_jakkula AIX 0 02-11-2006 01:20 AM
Replacing set of characters with a value of a variable prekida Shell Programming and Scripting 1 07-26-2005 08:14 PM
How to display unicode characters / unicode string jackdorso High Level Programming 3 05-20-2005 01:09 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-18-2008
roninuta's Avatar
roninuta roninuta is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 11
Help replacing or scrubbing unicode characters

I have a csv (tab delimited) file that is created by an application (that I didn't write).

Every so often it throw out a <U+FEFF> (Zero Width no break space) character at the begining of a tabbed field. The charcater is invisible to some editors, but it shows up bolded in less.

The issue is that these CSV files are being imported in a sql db and it's causing issues. I would like to find a way to scrub this out. As I have learned this is difficult, grep and sed won't find the unicode character (which is apparently UTF-16). I have no control over the originating application. I can only control for the output once it is written to a file.

Is there anything I can do to scrub these out? i already have a shell script that changes the line endings, is there something I can do in the bash?

Last edited by roninuta; 01-18-2008 at 03:26 PM.. Reason: update
  #2 (permalink)  
Old 01-18-2008
RTM's Avatar
RTM RTM is offline Forum Advisor  
Hog Hunter
  
 

Join Date: Apr 2002
Location: On my motorcycle
Posts: 3,039
Not sure it will work, but dos2unix may fix it. Check the man page - dos2unix and unix2dos should be on your system.
  #3 (permalink)  
Old 01-21-2008
adderek adderek is offline
Registered User
  
 

Join Date: Sep 2007
Location: Poland
Posts: 110
Do I understand it correctly that you want to frequently get rid of this character from some *.csv files? In my opinion best would be a simple C/C++ application that reads the file byte-by-byte and writes it byte-by-byte with skipping the unwanted ones. To improve performance you could optimize reads/writes.
  #4 (permalink)  
Old 01-21-2008
roninuta's Avatar
roninuta roninuta is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 11
yes basically

That is exactly what I am looking for. I was hoping there was something I could do in the bash, without having to dust off really old c skills (I mean really really old)
Closed Thread

Bookmarks

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:08 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0