Sponsored Content
Top Forums Programming string with invalid characters Post 302222841 by jim mcnamara on Thursday 7th of August 2008 03:43:29 PM
Old 08-07-2008
IF you mean C, then yes, you use a char pointer to step thru the source string, copying only good characters to the destination string, using ctype.h macros maybe like:
isascii(),
isspace(),
iscntrl()

to check the 'goodness' of the character. The definition of what is good is partly up to you - some chars like * are valid in filenames but can cause hell to break loose when you actually use them. Otherwise use tr like Franklin says.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Invalid Characters in the file.

I am working on AIX. We ftp files to a database. The flat files are having thousands of records and each record is having some 50 to 60 characters(there are fields having certain character length). In addition to some valid ascii characters some invalid characters like Å, å, Ä, ä or pipes creep in which... (5 Replies)
Discussion started by: kanu_pathak
5 Replies

2. UNIX for Dummies Questions & Answers

Invalid Characters in the file.

I am working on AIX. We ftp files to a database. The flat files are having thousands of records and each record is having some 50 to 60 characters(there are fields having certain character length). In addition to some valid ascii characters some invalid characters like Å, å, Ä, ä or pipes creep in which... (15 Replies)
Discussion started by: kanu_pathak
15 Replies

3. Shell Programming and Scripting

Add string after another string with special characters

Hello everyone, I'm writing a script to add a string to an XML file, right after a specified string that only occurs once in the file. For testing purposes I created a file 'testfile' that looks like this: 1 2 3 4 5 6 6 7 8 9 And this is the script as far as I've managed: ... (2 Replies)
Discussion started by: heliode
2 Replies

4. Shell Programming and Scripting

writing shell script to find line of invalid characters

Hi, I have to write s script to check an input file for invalid characters. In this script I have to find the exact line of the invalid character. If the input file contain 2 invalid character sat line 10 and 17, the script will show the value 10 and 17. Any help is appreciated. (3 Replies)
Discussion started by: beginner82
3 Replies

5. Shell Programming and Scripting

get certain characters in a string

Hi Everyone, I have a.txt 12341" <sip:191@vo.my>;asdf=q" 116aaaa<sip:00091@vo.my>;penguin would like to get the output 191 00091 Please advice. Thanks (4 Replies)
Discussion started by: jimmy_y
4 Replies

6. Shell Programming and Scripting

remove characters from string based on occurrence of a string

Hello Folks.. I need your help .. here the example of my problem..i know its easy..i don't all the commands in unix to do this especiallly sed...here my string.. dwc2_dfg_ajja_dfhhj_vw_dec2_dfgh_dwq desired output is.. dwc2_dfg_ajja_dfhhj it's a simple task with tail... (5 Replies)
Discussion started by: victor369
5 Replies

7. Shell Programming and Scripting

Remove invalid database characters on a file

Hi All - I'm building a script wherein it is design to remove characters that are not accepted on a non-unicode database. Examples are the following: ï,¿,½,Â,é, etc. I can easily sed those characters one-by-one but I there's a problem when other unicode characters are found. Is there any way to... (1 Reply)
Discussion started by: Jin_
1 Replies

8. UNIX for Dummies Questions & Answers

To get the invalid characters from a file

Hello, Can any one help me in below query to search all the invalid characters that UNIX cannot recognize from a file. can we do anything with the help of grep command or any other commands. Also, i am not sure what are the invalid characters present in the file. Many thanks in advance. ... (6 Replies)
Discussion started by: schandru
6 Replies

9. UNIX for Beginners Questions & Answers

Invalid arithmetic operator on string concatenation

Hello. LEAP_VERSION="4.2" export ARRAY_MAIN_REPO_LEAP=('zypper_local' 'openSUSE-Leap-'"$LEAP_VERSION"'-Non-Oss' 'openSUSE-Leap-'"$LEAP_VERSION"'-Oss' 'openSUSE-Leap-'"$LEAP_VERSION"'-Update' 'openSUSE-Leap-'"$LEAP_VERSION"'-Update-Non-Oss')Seems that the - is interpreted as a numeric... (2 Replies)
Discussion started by: jcdole
2 Replies

10. Shell Programming and Scripting

Outputting characters after a given string and reporting the characters in the row below --sed

I have this fastq file: @M04961:22:000000000-B5VGJ:1:1101:9280:7106 1:N:0:86 GGGGGGGGGGGGCATGAAAACATACAAACCGTCTTTCCAGAAATTGTTCCAAGTATCGGCAACAGCTTTATCAATACCATGAAAAATATCAACCACACCA +test-1 GGGGGGGGGGGGGGGGGCCGGGGGFF,EDFFGEDFG,@DGGCGGEGGG7DCGGGF68CGFFFGGGG@CGDGFFDFEFEFF:30CGAFFDFEFF8CAF;;8... (10 Replies)
Discussion started by: Xterra
10 Replies
ctype(3C)																 ctype(3C)

NAME
ctype, isalpha, isalnum, isascii, isblank, iscntrl, isdigit, islower, isprint, isspace, isupper, ispunct, isgraph, isxdigit - character handling SYNOPSIS
#include <ctype.h> int isalpha(int c); int isalnum(int c); int isascii(int c); int isblank(int c); int iscntrl(int c); int isdigit(int c); int isgraph(int c); int islower(int c); int isprint(int c); int ispunct(int c); int isspace(int c); int isupper(int c); int isxdigit(int c); These macros classify character-coded integer values. Each is a predicate returning non-zero for true, 0 for false. The behavior of these macros, except isascii(), is affected by the current locale (see setlocale(3C)). To modify the behavior, change the LC_TYPE category in setlocale(), that is, setlocale(LC_CTYPE, newlocale). In the "C" locale, or in a locale where character type information is not defined, characters are classified according to the rules of the US-ASCII 7-bit coded character set. The isascii() macro is defined on all integer values. The rest are defined only where the argument is an int, the value of which is repre- sentable as an unsigned char, or EOF, which is defined by the <stdio.h> header and represents end-of-file. Functions exist for all the macros defined below. To get the function form, the macro name must be undefined (for example, #undef isdigit). For macros described with Default and Standard conforming versions, standard-conforming behavior is provided for standard-conforming appli- cations (see standards(5)) and for applications that define __XPG4_CHAR_CLASS__ before including <ctype.h>. Default isalpha() Tests for any character for which isupper() or islower() is true. Standard conforming isalpha() Tests for any character for which isupper() or islower() is true, or any character that is one of the current locale- defined set of characters for which none of iscntrl(), isdigit(), ispunct(), or isspace() is true. In "C" locale, isalpha() returns true only for the characters for which isupper() or islower() is true. isalnum() Tests for any character for which isalpha() or isdigit() is true (letter or digit). isascii() Tests for any ASCII character, code between 0 and 0177 inclusive. isblank() Tests whether c is a character of class blank in the current locale. This macro/function is not available to applications conforming to standards prior to SUSv3. See standards(5) iscntrl() Tests for any ``control character'' as defined by the character set. isdigit() Tests for any decimal-digit character. Default isgraph() Tests for any character for which ispunct(), isupper(), islower(), and isdigit() is true. Standard conforming isgraph() Tests for any character for which isalnum() and ispunct() are true, or any character in the current locale-defined "graph" class which is neither a space ("") nor a character for which iscntrl() is true. islower() Tests for any character that is a lower-case letter or is one of the current locale-defined set of characters for which none of iscntrl(), isdigit(), ispunct(), isspace(), or isupper() is true. In the "C" locale, islower() returns true only for the characters defined as lower-case ASCII characters. Default isprint() Tests for any character for which ispunct(), isupper(), islower(), isdigit(), and the space character ("") is true. Standard conforming isprint() Tests for any character for which iscntrl() is false, and isalnum(), isgraph(), ispunct(), the space character (""), and the characters in the current locale-defined "print" class are true. ispunct() Tests for any printing character which is neither a space ("") nor a character for which isalnum() or iscntrl() is true. isspace() Tests for any space, tab, carriage-return, newline, vertical-tab or form-feed (standard white-space characters) or for one of the current locale-defined set of characters for which isalnum() is false. In the "C" locale, isspace() returns true only for the standard white-space characters. isupper() Tests for any character that is an upper-case letter or is one of the current locale-defined set of characters for which none of iscntrl(), isdigit(), ispunct(), isspace(), or islower() is true. In the "C" locale, isupper() returns true only for the characters defined as upper-case ASCII characters. Default isxdigit() Tests for any hexadecimal-digit character ([0-9], [A-F], or [a-f]). Standard conforming isxdigit() Tests for any hexadecimal-digit character ([0-9], [A-F], or [a-f] or the current locale-defined sets of characters repre- senting the hexadecimal digits 10 to 15 inclusive). In the "C" locale, only 0 1 2 3 4 5 6 7 8 9 A B C D E F a b c d e f are included. If the argument to any of the character handling macros is not in the domain of the function, the result is undefined. Otherwise, the macro or function returns non-zero if the classification is TRUE and 0 if the classification is FALSE. USAGE
These macros or functions can be used safely in multithreaded applications, as long as setlocale(3C) is not being called to change the locale. See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | |CSI |Enabled | |Interface Stability |Standard | |MT-Level |MT-Safe with exceptions | +-----------------------------+-----------------------------+ setlocale(3C), stdio(3C), ascii(5), environ(5), standards(5) 28 Jan 2005 ctype(3C)
All times are GMT -4. The time now is 02:17 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy