Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Sorry, I haven't been able to hobble this together... Post 302924174 by gusbrown on Thursday 6th of November 2014 06:15:30 PM
Old 11-06-2014
Sorry, I haven't been able to hobble this together...

I have a file containing about 100 lines, each with a ';' the end.

Each line is a string represented in UTF-16 hex and they vary in length.

I am thinking I ought to be able to use (g)awk to insert ',00,' after each two characters on each line in the file so that in the end, I have a comma-delimited UTF-16LE hex file:

From:
Code:
224C6F72656D20697073756D20646F6C6F722073697420616D65742C20636F6E73656374657475722061646970697363696E6720656C69742E2050656C6C656E74657371756520697073756D206D617373612200;
224C6F72656D20697073756D20646F6C6F722073697420616D65742C20636F6E73656374657475722061646970697363696E6720656C69742E2050656C6C656E74657371756520697073756D206D617373612200;

To:
Code:
22,00,4C,00,6F,00,72,00,65,00,6D,00,20,00,69,00,70,00,73,00,75,00,6D,00,20,00,64,00,6F,00,6C,00,6F,00,72,00,20,00,73,00,69,00,74,00,20,00,61,00,6D,00,65,00,74,00,2C,00,20,00,63,00,6F,00,6E,00,73,00,65,00,63,00,74,00,65,00,74,00,75,00,72,00,20,00,61,00,64,69,00,70,00,69,00,73,00,63,00,69,00,6E,00,67,00,20,00,65,00,6C,00,69,00,74,00,2E,00,20,00,50,00,65,00,6C,00,6C,00,65,00,6E,00,74,00,65,00,73,00,71,00,75,00,65,00,20,00,69,00,70,00,73,00,75,00,6D,00,20,00,6D,00,61,00,73,00,73,00,61,00,22,00,00;
22,00,4C,00,6F,00,72,00,65,00,6D,00,20,00,69,00,70,00,73,00,75,00,6D,00,20,00,64,00,6F,00,6C,00,6F,00,72,00,20,00,73,00,69,00,74,00,20,00,61,00,6D,00,65,00,74,00,2C,00,20,00,63,00,6F,00,6E,00,73,00,65,00,63,00,74,00,65,00,74,00,75,00,72,00,20,00,61,00,64,69,00,70,00,69,00,73,00,63,00,69,00,6E,00,67,00,20,00,65,00,6C,00,69,00,74,00,2E,00,20,00,50,00,65,00,6C,00,6C,00,65,00,6E,00,74,00,65,00,73,00,71,00,75,00,65,00,20,00,69,00,70,00,73,00,75,00,6D,00,20,00,6D,00,61,00,73,00,73,00,61,00,22,00,00;

I've fiddled around all day (on and off) and have nothing to show for my efforts. If any of you can show me the way, I'd be most appreciative.

Thanks,

gus

Moderator's Comments:
Mod Comment Please use code tags

Last edited by jim mcnamara; 11-06-2014 at 10:37 PM.. Reason: code tags
 

2 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

haven`t the right of root?

I install solaris 8. I want to use netconfig command, but it dispear "you haven`t the right",why? Is there somebody can help me? (3 Replies)
Discussion started by: yycokr
3 Replies

2. Shell Programming and Scripting

I thought I asked the question before but I haven't sorry

:D could any one answer my previous question... just looked through logg and found no such question that I had asked.. please any input would help \.. :confused: (2 Replies)
Discussion started by: moxxx68
2 Replies
base32::hex(n)							  Base32 encoding						    base32::hex(n)

__________________________________________________________________________________________________________________________________________________

NAME
base32::hex - base32 extended hex encoding SYNOPSIS
package require Tcl 8.4 package require base32::core ?0.1? package require base32::hex ?0.1? ::base32::hex::encode string ::base32::hex::decode estring _________________________________________________________________ DESCRIPTION
This package provides commands for encoding and decoding of strings into and out of the extended hex base32 encoding as specified in the RFC 3548bis draft. API
::base32::hex::encode string This command encodes the given string in extended hex base32 and returns the encoded string as its result. The result may be padded with the character = to signal a partial encoding at the end of the input string. ::base32::hex::decode estring This commands takes the estring and decodes it under the assumption that it is a valid extended hex base32 encoded string. The result of the decoding is returned as the result of the command. Note that while the encoder will generate only uppercase characters this decoder accepts input in lowercase as well. The command will always throw an error whenever encountering conditions which signal some type of bogus input, namely if [1] the input contains characters which are not valid output of a extended hex base32 encoder, [2] the length of the input is not a multiple of eight, [3] padding appears not at the end of input, but in the middle, [4] the padding has not of length six, four, three, or one characters, CODE MAP
The code map used to convert 5-bit sequences is shown below, with the numeric id of the bit sequences to the left and the character used to encode it to the right. The important feature of the extended hex mapping is that the first 16 codes map to the digits and hex characters. 0 0 9 9 18 I 27 R 1 1 10 A 19 J 28 S 2 2 11 B 20 K 29 T 3 3 12 C 21 L 30 U 4 4 13 D 22 M 31 V 5 5 14 E 23 N 6 6 15 F 24 O 7 7 16 G 25 P 8 8 17 H 26 Q BUGS, IDEAS, FEEDBACK This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category base32 of the Tcllib SF Trackers [http://sourceforge.net/tracker/?group_id=12883]. Please also report any ideas for enhancements you may have for either package and/or documentation. KEYWORDS
base32, hex, rfc3548 COPYRIGHT
Copyright (c) Public domain base32 0.1 base32::hex(n)
All times are GMT -4. The time now is 10:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy