add the utitle encoder, the reverse of ctitle
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@8356 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
854e9a0861
commit
a9769137ed
1 changed files with 27 additions and 0 deletions
|
|
@ -179,6 +179,32 @@ String *Swig_string_ctitle(String *s) {
|
|||
return ns;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_string_utitle()
|
||||
*
|
||||
* This is the reverse case of ctitle, ie
|
||||
*
|
||||
* CamelCase -> camel_case
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_string_utitle(String *s) {
|
||||
String *ns;
|
||||
int first = 0;
|
||||
int c;
|
||||
ns = NewStringEmpty();
|
||||
|
||||
Seek(s,0,SEEK_SET);
|
||||
while ((c = Getc(s)) != EOF) {
|
||||
if (isupper(c)) {
|
||||
if (!first) Putc('_',ns);
|
||||
first = 1;
|
||||
continue;
|
||||
}
|
||||
Putc(tolower(c),ns);
|
||||
}
|
||||
return ns;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_string_typecode()
|
||||
*
|
||||
|
|
@ -696,6 +722,7 @@ Swig_init() {
|
|||
DohEncoding("lower", Swig_string_lower);
|
||||
DohEncoding("title", Swig_string_title);
|
||||
DohEncoding("ctitle", Swig_string_ctitle);
|
||||
DohEncoding("utitle", Swig_string_utitle);
|
||||
DohEncoding("typecode",Swig_string_typecode);
|
||||
DohEncoding("mangle",Swig_string_emangle);
|
||||
DohEncoding("command",Swig_string_command);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue