quote man page on Plan9

Man page or keyword search:  
man Server   549 pages
apropos Keyword Search (all sections)
Output format
Plan9 logo
[printable version]

QUOTE(2)							      QUOTE(2)

NAME
       quotestrdup,    quoterunestrdup,	   unquotestrdup,   unquoterunestrdup,
       quotestrfmt, quoterunestrfmt, quotefmtinstall, doquote, needsrcquote  -
       quoted character strings

SYNOPSIS
       #include <u.h>
       #include <libc.h>

       char *quotestrdup(char *s)

       Rune *quoterunestrdup(Rune *s)

       char *unquotestrdup(char *s)

       Rune *unquoterunestrdup(Rune *s)

       int quotestrfmt(Fmt*)

       int quoterunestrfmt(Fmt*)

       void quotefmtinstall(void)

       int (*doquote)(int c)

       int needsrcquote(int c)

DESCRIPTION
       These  routines manipulate character strings, either adding or removing
       quotes as necessary.  In the quoted form, the strings are in the	 style
       of  rc(1),  with single quotes surrounding the string.  Embedded single
       quotes are indicated by a doubled single quote.	For instance,

	      Don't worry!

       when quoted becomes

	      'Don''t worry!'

       The empty string is represented by two quotes, ''.

       The first four functions act as variants	 of  strdup  (see  strcat(2)).
       Each returns a freshly allocated copy of the string, created using mal‐
       loc(2).	Quotestrdup returns a quoted copy of  s,  while	 unquotestrdup
       returns	a  copy	 of s with the quotes evaluated.  The rune versions of
       these functions do the same for strings (see runestrcat(2)).

       The string returned by quotestrdup or quoterunestrdup has the following
       properties:

       1.     If the original string s is empty, the returned string is ''.

       2.     If  s  contains  no  quotes,  blanks, or control characters, the
	      returned string is identical to s.

       3.     If s needs quotes to  be	added,	the  first  character  of  the
	      returned	string	will  be  a  quote.   For example, hello world
	      becomes 'hello world' not hello' 'world.

       The function pointer doquote is nil by  default.	  If  it  is  non-nil,
       characters are passed to that function to see if they should be quoted.
       This mechanism allows programs to specify that  characters  other  than
       blanks,	control	 characters,  or  quotes be quoted.  Regardless of the
       return value of *doquote, blanks, control characters,  and  quotes  are
       always  quoted.	 Needsrcquote  is  provided as a doquote function that
       flags any character special to rc(1).

       Quotestrfmt and quoterunestrfmt are print(2) formatting	routines  that
       produce	quoted	strings as output.  They may be installed by hand, but
       quotefmtinstall installs them under the standard	 format	 characters  q
       and  Q.	 (They are not installed automatically.)  If the format string
       includes the alternate format character #, for example %#q, the printed
       string will always be quoted; otherwise quotes will only be provided if
       necessary to avoid ambiguity.  In <libc.h> there are #pragma statements
       so  the	compiler  can  type-check uses of %q and %Q in print(2) format
       strings.

SOURCE
       /sys/src/libc/port/quote.c
       /sys/src/libc/fmt/fmtquote.c

SEE ALSO
       rc(1), malloc(2), print(2), strcat(2)

								      QUOTE(2)
[top]
                             _         _         _ 
                            | |       | |       | |     
                            | |       | |       | |     
                         __ | | __ __ | | __ __ | | __  
                         \ \| |/ / \ \| |/ / \ \| |/ /  
                          \ \ / /   \ \ / /   \ \ / /   
                           \   /     \   /     \   /    
                            \_/       \_/       \_/ 
More information is available in HTML format for server Plan9

List of man pages available for Plan9

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net