Sponsored Content
Top Forums UNIX for Advanced & Expert Users Another binary manipulation thread. Post 302845069 by wisecracker on Wednesday 21st of August 2013 04:52:28 AM
Old 08-21-2013
Hi DGPickett...

I appreciate that the _string_ is not an actual character zero, but the original code replaces character zero with two characters - "\0".

I am on holiday/vacation ATM so gimme a bit of time to INPUT to a variable with the two pseudo-zero characters for an actual character zero and 0xFF as a single byte, a total of three characters...

If I get stuck I will certainly admit it... ;o)

---------- Post updated 21-08-13 at 09:52 AM ---------- Previous update was 20-08-13 at 10:29 PM ----------

Hi DGPickett...

Slightly bigger than 3 bytes... ;o)

This generates a variable "text" 10 bytes long containing three "\0" pseudo-zeros and other non-ascii characters. The binary file generated is either 7 or 10 bytes in size......
Code:
Last login: Wed Aug 21 08:53:01 on ttys000
AMIGA:barrywalker~> read -p "INPUT:- " character
INPUT:- \\\xFF\\\\0\\\x7F\\\\0\\\x80\\\\0\\\xFF
AMIGA:barrywalker~> text=`echo -e -n "$character"`
AMIGA:barrywalker~> echo -n "$text" > /tmp/bin.dat
AMIGA:barrywalker~> hexdump -C /tmp/bin.dat
00000000  ff 5c 30 7f 5c 30 80 5c  30 ff                    |.\0.\0.\0.|
0000000a
AMIGA:barrywalker~> echo -e -n "$text" > /tmp/bin.dat
AMIGA:barrywalker~> hexdump -C /tmp/bin.dat
00000000  ff 00 7f 00 80 00 ff                              |.......|
00000007
AMIGA:barrywalker~> # Real string length should be 10 bytes.
AMIGA:barrywalker~> echo "${#text}"
10
AMIGA:barrywalker~> _

This is the best workaround I can do WRT to byte value zero and reading from the keyboard.
 

4 More Discussions You Might Find Interesting

1. Programming

How to cancel a thread safely from the initial thread?

how about asynchronous canceling? or with signal? if with signal whether it effects the process? my english so badly :( :( (1 Reply)
Discussion started by: alan.zhao
1 Replies

2. Shell Programming and Scripting

Convert binary file to csv and then back to the binary format

Hello *nix specialists, Im working for a non profit organisation in Germany to transport DSL over WLAN to people in areas without no DSL. We are using Linksys WRT 54 router with DD-WRT firmware There are at the moment over 180 router running but we have to change some settings next time. So my... (7 Replies)
Discussion started by: digidax
7 Replies

3. Shell Programming and Scripting

Another Building Block, Binary File Manipulation...

Apologies for any typos, and IF this has been done before... This is yet another building block. The code generates a 256 byte binary file of _characters_ 0x00 to 0xFF for general usage and generates another binary file manipulated in a basic way. I need this facility for a kids project I am... (0 Replies)
Discussion started by: wisecracker
0 Replies

4. Forum Support Area for Unregistered Users & Account Problems

Not able to post thread/reply to thread

Dear Moderator I am not able to post any new thread or post reply to mine old thread. Kindly help as i am stuck on one problem and needed suggestion. Regards Jaydeep (1 Reply)
Discussion started by: jaydeep_sadaria
1 Replies
GB18030(5)						      BSD File Formats Manual							GB18030(5)

NAME
gb18030 -- GB 18030 encoding method for Chinese text SYNOPSIS
ENCODING "GB18030" DESCRIPTION
The GB18030 encoding implements GB 18030-2000, a PRC national standard for the encoding of Chinese characters. It is a superset of the older GB 2312-1980 and GBK encodings, and incorporates Unicode's Unihan Extension A completely. It also provides code space for all Unicode 3.0 code points. Multibyte characters in the GB18030 encoding can be one byte, two bytes, or four bytes long. There are a total of over 1.5 million code positions. GB 11383-1981 (ASCII) characters are represented by single bytes in the range 0x00 to 0x7F. Chinese characters are represented as either two bytes or four bytes. Characters that are represented by two bytes begin with a byte in the range 0x81-0xFE and end with a byte either in the range 0x40-0x7E or 0x80-0xFE. Characters that are represented by four bytes begin with a byte in the range 0x81-0xFE, have a second byte in the range 0x30-0x39, a third byte in the range 0x81-0xFE and a fourth byte in the range 0x30-0x39. SEE ALSO
euc(5), gb2312(5), gbk(5), utf8(5) Chinese National Standard GB 18030-2000: Information Technology -- Chinese ideograms coded character set for information interchange -- Extension for the basic set, March 2000. The Unicode Standard, Version 3.0, The Unicode Consortium, 2000. STANDARDS
The GB18030 encoding is believed to be compatible with GB 18030-2000. BSD
August 10, 2003 BSD
All times are GMT -4. The time now is 02:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy