Sponsored Content
Top Forums Shell Programming and Scripting sed replacement in unicode file Post 302295568 by rikxik on Sunday 8th of March 2009 11:51:27 PM
Old 03-09-2009
You can try this to join the lines and remove non-ascii characters:
Code:
perl -pe 's/\000/ /g; s/[^[:ascii:]]//g; s/\\\n//g;s/ +//g' win.reg

Btw, it seem more like you have plenty of ^@ (nul) which is actually ascii. So 's/\000/ /g' is to remove the nul character. Let us know how it goes.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Replacement using sed

Hi I have the following file that i need to run a sed command on 1<tab>running 2<tab>running 3<tab>running 4<tab>running I want to be able to replace a line i.e the second one with '2<tab>failed'. As the first number is unique that can be used to search for the relevant line (using ^2 i... (5 Replies)
Discussion started by: handak9
5 Replies

2. Programming

How to display unicode characters / unicode string

I have a stream of characters like "\u8BBE\u5907\u7BA1" and i want to display it. I tried following things already without any luck. 1) printf("%s",L("\u8BBE\u5907\u7BA1")); 2) printf("%lc",0x8BBE); 3) setlocale followed by fwide followed by wprintf 4) also changed the local manually... (3 Replies)
Discussion started by: jackdorso
3 Replies

3. Shell Programming and Scripting

Need Replacement for sed

Hi Can anyone provide me the replacement of sed with xargs perl syntax for the below sed -e :a -e '/;$/!N;s/\n//; ta' -e 's/;$//' This should be without looping has to take minimal time for search (0 Replies)
Discussion started by: dbsurf
0 Replies

4. Shell Programming and Scripting

sed xml file multiple line replacement

I have a file called config.xml, it's a simple xml file, and I need use sed/awk to erase some lines. <machine xsi:type="unix-machineType"> <name>server1</name> <node-manager> <name>server1</name> <listen-address>server1</listen-address> </node-manager> ... (3 Replies)
Discussion started by: cbo0485
3 Replies

5. Shell Programming and Scripting

How do I replace a unicode character using sed

I have a unicode character {Unicode: 0x1C} in my file and I need to replace it with a blank. How would a sed command look like? cat file1 | sed "s/&#x28;//g;" > file2 Is X28 the right value for this Unicode character?? (4 Replies)
Discussion started by: Hangman2
4 Replies

6. Shell Programming and Scripting

sed replacement in file when line is in a variable

Hi, I have a file where I want to replace the 15th field separated by comma, only on specific lines matching lots of different conditions. I have managed to read the file line by line, within the loop my line is held in a variable called $line I assume this will be using sed (maybe... (5 Replies)
Discussion started by: jpt123
5 Replies

7. Shell Programming and Scripting

sed - replacement file path with variable - Escaping / character

Hi,, I have the line below in a file: $!VarSet |LFDSFN1| = '"E:\APC\Trials\20140705_427_Prototype Trial\Data\T4_20140705_Trial_Cycle_Data_13_T_Norm.txt" "VERSION=100 FILEEXT=\"*.txt\" FILEDESC=\"General Text\" "+""+"TITLE{SEARCH=NONE NAME=\"New Dataset\" LINE=1I want to write a script to change... (2 Replies)
Discussion started by: carlr
2 Replies

8. Shell Programming and Scripting

Sed: how to use file contents in replacement string

I want to replace a string by contents of file. I am trying the following sed command: cat sample | sed "s^<enter description here>^`cat details`^" But it is not working. a=`cat details` and using $a will not help since it will affect the whitespaces. What am I missing in the above sed... (5 Replies)
Discussion started by: anand_bh
5 Replies

9. Shell Programming and Scripting

Solution for replacement of 4th column with 3rd column in a file using awk/sed preserving delimters

input "A","B","C,D","E","F" "S","T","U,V","W","X" "AA","BB","CC,DD","EEEE","FFF" required output: "A","B","C,D","C,D","F" "S", T","U,V","U,V","X" "AA","BB","CC,DD","CC,DD","FFF" tried using awk but double quotes not preserving for every field. any help to solve this is much... (5 Replies)
Discussion started by: khblts
5 Replies

10. Shell Programming and Scripting

Multiple Replacement in a Text File in one operation (sed/awk) ?

Hi all, Saying we have two files: 1. A "Reference File" whose content is "Variable Name": "Variable Value" 2. A "Model File" whose content is a model program in which I want to substitute "VariableName" with their respective value to produce a third file "Program File" which would be a... (4 Replies)
Discussion started by: dae
4 Replies
WCSRTOMBS(3)						   BSD Library Functions Manual 					      WCSRTOMBS(3)

NAME
wcsrtombs -- converts a wide-character string to a multibyte character string (restartable) LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <wchar.h> size_t wcsrtombs(char * restrict s, const wchar_t ** restrict pwcs, size_t n, mbstate_t * restrict ps); DESCRIPTION
The wcsrtombs() converts the nul-terminated wide-character string indirectly pointed to by pwcs to the corresponding multibyte character string, and stores it in the array pointed to by s. The conversion stops due to the following reasons: o The conversion reaches a nul wide character. In this case, the nul wide character is also converted. o The wcsrtombs() has already stored n bytes in the array pointed to by s. o The conversion encounters an invalid character. Each character will be converted as if wcrtomb(3) is continuously called, except the internal state of wcrtomb(3) will not be affected. After conversion, if s is not a null pointer, the pointer object pointed to by pwcs is a null pointer (if the conversion is stopped due to reaching a nul wide character) or the first byte of the character just after the last character converted. If s is not a null pointer and the conversion is stopped due to reaching a nul wide character, wcsrtombs() places the state object pointed to by ps to an initial state after the conversion is taken place. The behaviour of wcsrtombs() is affected by the LC_CTYPE category of the current locale. These are the special cases: s == NULL wcsrtombs() returns the number of bytes to store the whole multibyte character string corresponding to the wide-character string pointed to by pwcs, not including the terminating nul byte. In this case, n is ignored. pwcs == NULL || *pwcs == NULL Undefined (may cause the program to crash). ps == NULL wcsrtombs() uses its own internal state object to keep the conversion state, instead of ps mentioned in this manual page. Calling any other functions in Standard C Library (libc, -lc) never changes the internal state of wcsrtombs(), which is ini- tialized at startup time of the program. RETURN VALUES
wcsrtombs() returns: 0 or positive Number of bytes stored in the array pointed to by s, except for a nul byte. There are no cases that the value returned is greater than n (unless s is a null pointer). If the return value is equal to n, the string pointed to by s will not be nul- terminated. (size_t)-1 pwcs points to a string containing an invalid wide character. The wcsrtombs() also sets errno to indicate the error. ERRORS
wcsrtombs() may cause an error in the following case: [EILSEQ] pwcs points to a string containing an invalid wide character. SEE ALSO
setlocale(3), wcrtomb(3), wcstombs(3) STANDARDS
The wcsrtombs() function conforms to ANSI X3.159-1989 (``ANSI C89''). The restrict qualifier is added at ISO/IEC 9899:1999 (``ISO C99''). BSD
August 8, 2006 BSD
All times are GMT -4. The time now is 07:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy