Sponsored Content
Top Forums UNIX for Advanced & Expert Users Another binary manipulation thread. Post 302849007 by DGPickett on Friday 30th of August 2013 03:37:47 PM
Old 08-30-2013
There is a wealth of possibilities, between the readline options, stty raw, and IFS, but so many tools do not deal with null, it's hard to even test. If you bash "read =n 1" a null into a variable, is it hard to tell the variable is the empty string '' or ""?

To write it out, one might use the printf character option, treating it as a special case and providing the null as a zero char (int) value. Once you get to treating it as a special case, you can write it with something like "echo '\0\c' ".

$IFS characters are another challenge, but if you use "read -n 1" you could do your own $IFS processing if any, setting $IFS to '' or unsetting it.
 

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
copystr(9r)															       copystr(9r)

NAME
copystr - General: Copies a null-terminated character string with a specified limit SYNOPSIS
int copystr( char *s1, char *s2, u_int maxlength, u_int *ncopiedaddr ); ARGUMENTS
Specifies a pointer to a string (an array of characters terminated by a null character). Specifies a pointer to a buffer of at least maxlength characters. Specifies the maximum number of characters to copy. Specifies the address of an integer to receive the number of copied characters. DESCRIPTION
The copystr routine copies string s1 to the buffer pointed to by s2. The routine stops after copying a null character or after copying maxlength characters, whichever comes first. The s2 buffer is not padded with null characters to maxlength. The copystr routine returns the number of characters copied in the location pointed to by ncopiedaddr. Note that the character size is 1 byte. RETURN VALUES
Upon successful completion, copystr returns the value 0 (zero). Otherwise, it can return the following error: The string length, s1, exceeds the maximum number of characters, maxlength. SEE ALSO
Routines: bcopy(9r), blkclr(9r), ovbcopy(9r), strcpy(9r), strncpy(9r) copystr(9r)
All times are GMT -4. The time now is 06:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy