Audio-TagLib
view release on metacpan or search on metacpan
xs/tstring.xs view on Meta::CPAN
default:
/* any other encodings converted to utf8 */
//sv_dump(ST(1));
//printf("fromcode = %s\n", fromcode);
// Patch Festus-02 tstring.xs:
// if(!(codec = iconv_open("UTF8", fromcode)))
const char *from_code;
if(strncasecmp(fromcode, "UTF8", 4) == 0) {
from_code = "UTF-8";
} else if(strncasecmp(fromcode, "UTF16BE", 7) == 0) {
from_code = "UTF-16BE";
} else if(strncasecmp(fromcode, "UTF16LE", 7) == 0) {
from_code = "UTF-16LE";
} else if(strncasecmp(fromcode, "UTF16", 5) == 0) {
from_code = "UTF-16";
} else
from_code = fromcode;
if(!(codec = iconv_open("UTF-8", from_code)))
// end of Festus-02
croak("iconv_open failed, check your encode");
/* inlen MUST be the extract byte length of string */
/* the terminal '\0' should NOT be included in length */
inlen = SvCUR(ST(1));
utf8len = outlen = (inlen/1024+1)*1024;
utf8 = new char[outlen];
if(!utf8)
croak("can't allocate memory for string");
inbuf = SvPVX(ST(1));
outbuf = utf8;
iconv(codec, NULL, NULL, NULL, NULL);
if(iconv_wrap(codec, &inbuf, &inlen, &outbuf, &outlen) == -1) {
sprintf(errmsg, "error converting from %s to UTF8",
fromcode);
delete [] utf8;
iconv_close(codec);
croak(errmsg);
}
//printf("inlen = %d, outlen = %d\n", inlen, outlen);
/* add terminating '\0' to the end of output string */
utf8[utf8len - outlen] = '\0';
//for(int i = 0; i < strlen(utf8)+1; i++) {
// printf("%d: %#d\n", i, utf8[i]);
//}
iconv_close(codec);
RETVAL = new TagLib::String(utf8, TagLib::String::UTF8);
delete [] utf8;
}
}
OUTPUT:
RETVAL
void
TagLib::String::DESTROY()
CODE:
/* skip TagLib::String::null */
if(THIS != &(TagLib::String::null) && !SvREADONLY(SvRV(ST(0))))
delete THIS;
################################################################
#
# std::string to8Bit(bool unicode=false) const
#
# return a PV instead
# set UTF8 flag accordingly
#
################################################################
SV *
TagLib::String::to8Bit(unicode = false)
bool unicode
INIT:
std::string string = THIS->to8Bit(unicode);
CODE:
RETVAL = newSVpv(string.c_str(), 0);
#ifdef PERLV_LESS_12
if(sv_len_utf8(RETVAL) != sv_len(RETVAL))
#else
if(!is_ascii_string((const U8 *)string.c_str(), 0)) /* RT 85621 */
#endif
SvUTF8_on(RETVAL);
OUTPUT:
RETVAL
SV *
TagLib::String::toCString(unicode = false)
bool unicode
INIT:
const char *c_str = THIS->toCString(unicode);
CODE:
RETVAL = newSVpv(c_str, 0);
#ifdef PERLV_LESS_12
if(sv_len_utf8(RETVAL) != sv_len(RETVAL))
#else
if(!is_ascii_string((const U8 *)c_str,0)) /* RT 85621 */
#endif
SvUTF8_on(RETVAL);
OUTPUT:
RETVAL
TagLib::String::Iterator *
TagLib::String::begin()
CODE:
RETVAL = new TagLib::String::Iterator(THIS->begin());
OUTPUT:
RETVAL
################################################################
#
# ConstIterator begin() const
# not exported
#
################################################################
TagLib::String::Iterator *
TagLib::String::end()
CODE:
RETVAL = new TagLib::String::Iterator(THIS->end());
OUTPUT:
RETVAL
################################################################
#
# ConstIterator end() const
# not exported
#
################################################################
int
TagLib::String::find(s, offset = 0)
TagLib::String * s
int offset
CODE:
RETVAL = THIS->find(*s, offset);
OUTPUT:
RETVAL
TagLib::String *
TagLib::String::substr(position, n = 0xffffffff)
unsigned int position
unsigned int n
CODE:
RETVAL = new TagLib::String(THIS->substr(position, n));
OUTPUT:
RETVAL
void
TagLib::String::append(s)
TagLib::String * s
( run in 0.643 second using v1.01-cache-2.11-cpan-39bf76dae61 )