diff -ur swfmill-0.2.12/src/SWF.h swfmill-0.2.12.enc/src/SWF.h --- swfmill-0.2.12/src/SWF.h 2007-01-25 20:59:55.000000000 +0900 +++ swfmill-0.2.12.enc/src/SWF.h 2008-01-24 18:11:50.000000000 +0900 @@ -28,6 +28,9 @@ char tagVersion; bool alpha; bool many_shapes; + + bool convertEncoding; + const char *swf_encoding; int fillBits; int lineBits; diff -ur swfmill-0.2.12/src/SWFFile.cpp swfmill-0.2.12.enc/src/SWFFile.cpp --- swfmill-0.2.12/src/SWFFile.cpp 2006-07-20 22:57:25.000000000 +0900 +++ swfmill-0.2.12.enc/src/SWFFile.cpp 2008-01-24 18:11:50.000000000 +0900 @@ -198,7 +198,7 @@ xmlDocPtr doc = getXML( ctx ); if( !doc ) goto fail; - xmlDocDumpFormatMemory( doc, (xmlChar**)&data, &size, 1 ); + xmlDocDumpFormatMemoryEnc( doc, (xmlChar**)&data, &size, "UTF-8", 1 ); if( size ) fwrite( data, size, 1, fp ); diff -ur swfmill-0.2.12/src/SWFReader.cpp swfmill-0.2.12.enc/src/SWFReader.cpp --- swfmill-0.2.12/src/SWFReader.cpp 2007-01-16 07:27:04.000000000 +0900 +++ swfmill-0.2.12.enc/src/SWFReader.cpp 2008-01-24 18:11:50.000000000 +0900 @@ -143,9 +143,12 @@ char *Reader::getString() { byteAlign(); - int len = strlen((const char *)&data[pos]); - pos += len+1; - return strdup( (const char *)&data[pos-(len+1)] ); + const char *src = (const char*)&data[pos]; + size_t len = strlen(src) + 1; + char *dst = new char[len]; + memcpy( dst, src, len ); + pos += len; + return( dst ); } char *Reader::getPString() { diff -ur swfmill-0.2.12/src/gSWFBasics.cpp swfmill-0.2.12.enc/src/gSWFBasics.cpp --- swfmill-0.2.12/src/gSWFBasics.cpp 2007-01-25 20:59:55.000000000 +0900 +++ swfmill-0.2.12.enc/src/gSWFBasics.cpp 2008-01-24 18:11:50.000000000 +0900 @@ -9,7 +9,7 @@ // ------------ context structure -Context::Context() { +Context::Context() : swf_encoding(0) { swfVersion = 0; transientPropsToXML = false; debugTrace = false; @@ -17,6 +17,7 @@ isLast = false; tagVersion = 0; quiet = false; + convertEncoding = false; fillBits = 0; lineBits = 0; glyphBits = 0; @@ -172,7 +173,7 @@ String::~String() { - if( value ) delete value; + if( value ) delete[] value; } @@ -1036,7 +1037,7 @@ Symbol::~Symbol() { - if( name ) delete name; + if( name ) delete[] name; } @@ -1077,7 +1078,7 @@ Parameter::~Parameter() { - if( name ) delete name; + if( name ) delete[] name; } @@ -2320,7 +2321,7 @@ UnknownFilter::~UnknownFilter() { - if( data ) delete data; + if( data ) delete[] data; } @@ -3346,7 +3347,7 @@ UnknownTag::~UnknownTag() { - if( data ) delete data; + if( data ) delete[] data; } @@ -3706,7 +3707,7 @@ DefineFontInfo::~DefineFontInfo() { - if( nameData ) delete nameData; + if( nameData ) delete[] nameData; } @@ -4286,7 +4287,7 @@ DefineFontInfo2::~DefineFontInfo2() { - if( nameData ) delete nameData; + if( nameData ) delete[] nameData; } @@ -4754,7 +4755,7 @@ PlaceObject2::~PlaceObject2() { - if( name ) delete name; + if( name ) delete[] name; } @@ -4985,9 +4986,9 @@ DefineEditText::~DefineEditText() { - if( variableName ) delete variableName; + if( variableName ) delete[] variableName; - if( initialText ) delete initialText; + if( initialText ) delete[] initialText; } @@ -5300,7 +5301,7 @@ FrameLabel::~FrameLabel() { - if( label ) delete label; + if( label ) delete[] label; } @@ -5495,7 +5496,7 @@ DefineFont2::~DefineFont2() { - if( name ) delete name; + if( name ) delete[] name; } @@ -5812,7 +5813,7 @@ Import::~Import() { - if( url ) delete url; + if( url ) delete[] url; } @@ -5888,7 +5889,7 @@ SoundStreamBlock::~SoundStreamBlock() { - if( data ) delete data; + if( data ) delete[] data; } @@ -6167,7 +6168,7 @@ PlaceObject3::~PlaceObject3() { - if( name ) delete name; + if( name ) delete[] name; } @@ -6411,7 +6412,7 @@ ImportAssets2::~ImportAssets2() { - if( url ) delete url; + if( url ) delete[] url; } @@ -6742,7 +6743,7 @@ StackString::~StackString() { - if( value ) delete value; + if( value ) delete[] value; } @@ -7005,7 +7006,7 @@ UnknownAction::~UnknownAction() { - if( data ) delete data; + if( data ) delete[] data; } @@ -8710,9 +8711,9 @@ GetURL::~GetURL() { - if( url ) delete url; + if( url ) delete[] url; - if( target ) delete target; + if( target ) delete[] target; } @@ -8854,7 +8855,7 @@ SetTarget::~SetTarget() { - if( label ) delete label; + if( label ) delete[] label; } @@ -8885,7 +8886,7 @@ GotoLabel::~GotoLabel() { - if( label ) delete label; + if( label ) delete[] label; } @@ -8969,7 +8970,7 @@ DeclareFunction2::~DeclareFunction2() { - if( name ) delete name; + if( name ) delete[] name; } @@ -9308,7 +9309,7 @@ DeclareFunction::~DeclareFunction() { - if( name ) delete name; + if( name ) delete[] name; } diff -ur swfmill-0.2.12/src/gSWFParseXML.cpp swfmill-0.2.12.enc/src/gSWFParseXML.cpp --- swfmill-0.2.12/src/gSWFParseXML.cpp 2007-01-25 20:59:55.000000000 +0900 +++ swfmill-0.2.12.enc/src/gSWFParseXML.cpp 2008-01-24 18:11:50.000000000 +0900 @@ -4,8 +4,58 @@ #include #include #include "base64.h" +#include +#include namespace SWF { +char *fromXmlChar(const Context *ctx, const xmlChar *from_str) { + if (ctx->convertEncoding) { + size_t len = strlen((const char *)from_str); + iconv_t cd = iconv_open(ctx->swf_encoding, "UTF-8"); + if (cd < 0) { + fprintf(stderr, "iconv_open failed.\n"); + char *buf = new char[1]; + buf[0] = '\0'; + return buf; + } + size_t buf_size = (len + 1) * 2; + for (;;) { + char * const dst = new char[buf_size]; + size_t inbytesleft = len; + size_t outbytesleft = buf_size - 1; // reserve 1 byte for '\0' + char *pin = (char*)from_str; + char *pout = dst; + bool expandbuf = false; + + while (inbytesleft > 0) { + size_t r = iconv(cd, &pin, &inbytesleft, &pout, &outbytesleft); + if (r == (size_t)-1) { + if (errno == E2BIG) { + expandbuf = true; + } else { + // bad input charctor + fprintf(stderr, "iconv failed: %s\n", from_str); + } + break; + } + } + if (expandbuf) { + iconv(cd, 0, 0, 0, 0); + delete[] dst; + buf_size *= 2; + continue; + } + *pout = '\0'; + iconv_close(cd); + return dst; + } + } else { + size_t len = strlen((const char *)from_str) + 1; + char *buf = new char[len]; + strcpy(buf, (const char *)from_str); + return buf; + } +} void Rectangle::parseXML( xmlNodePtr node, Context *ctx ) { @@ -123,7 +173,8 @@ tmp = xmlGetProp( node, (const xmlChar *)"value" ); if( tmp ) { - value = strdup((const char *)tmp); + char *val = fromXmlChar(ctx, (const xmlChar*)tmp); + value = val; } else { fprintf(stderr,"WARNING: no value property in %s element\n", (const char *)node->name ); value = strdup("[undefined]"); @@ -1109,7 +1160,8 @@ tmp = xmlGetProp( node, (const xmlChar *)"name" ); if( tmp ) { - name = strdup((const char *)tmp); + char *val = fromXmlChar(ctx, (const xmlChar*)tmp); + name = val; } else { fprintf(stderr,"WARNING: no name property in %s element\n", (const char *)node->name ); name = strdup("[undefined]"); @@ -1134,7 +1186,8 @@ tmp = xmlGetProp( node, (const xmlChar *)"name" ); if( tmp ) { - name = strdup((const char *)tmp); + char *val = fromXmlChar(ctx, (const xmlChar*)tmp); + name = val; } else { fprintf(stderr,"WARNING: no name property in %s element\n", (const char *)node->name ); name = strdup("[undefined]"); @@ -5378,7 +5431,8 @@ tmp = xmlGetProp( node, (const xmlChar *)"name" ); if( tmp ) { - name = strdup((const char *)tmp); + char *val = fromXmlChar(ctx, (const xmlChar*)tmp); + name = val; } else { fprintf(stderr,"WARNING: no name property in %s element\n", (const char *)node->name ); name = strdup("[undefined]"); @@ -5789,7 +5843,8 @@ tmp = xmlGetProp( node, (const xmlChar *)"variableName" ); if( tmp ) { - variableName = strdup((const char *)tmp); + char *val = fromXmlChar(ctx, (const xmlChar*)tmp); + variableName = val; } else { fprintf(stderr,"WARNING: no variableName property in %s element\n", (const char *)node->name ); variableName = strdup("[undefined]"); @@ -5807,7 +5862,8 @@ tmp = xmlGetProp( node, (const xmlChar *)"initialText" ); if( tmp ) { - initialText = strdup((const char *)tmp); + char *val = fromXmlChar(ctx, (const xmlChar*)tmp); + initialText = val; } else { fprintf(stderr,"WARNING: no initialText property in %s element\n", (const char *)node->name ); initialText = strdup("[undefined]"); @@ -5878,7 +5934,8 @@ tmp = xmlGetProp( node, (const xmlChar *)"label" ); if( tmp ) { - label = strdup((const char *)tmp); + char *val = fromXmlChar(ctx, (const xmlChar*)tmp); + label = val; } else { fprintf(stderr,"WARNING: no label property in %s element\n", (const char *)node->name ); label = strdup("[undefined]"); @@ -6122,7 +6179,8 @@ tmp = xmlGetProp( node, (const xmlChar *)"name" ); if( tmp ) { - name = strdup((const char *)tmp); + char *val = fromXmlChar(ctx, (const xmlChar*)tmp); + name = val; } else { fprintf(stderr,"WARNING: no name property in %s element\n", (const char *)node->name ); name = strdup("[undefined]"); @@ -6580,7 +6638,8 @@ tmp = xmlGetProp( node, (const xmlChar *)"url" ); if( tmp ) { - url = strdup((const char *)tmp); + char *val = fromXmlChar(ctx, (const xmlChar*)tmp); + url = val; } else { fprintf(stderr,"WARNING: no url property in %s element\n", (const char *)node->name ); url = strdup("[undefined]"); @@ -7005,7 +7064,8 @@ tmp = xmlGetProp( node, (const xmlChar *)"name" ); if( tmp ) { - name = strdup((const char *)tmp); + char *val = fromXmlChar(ctx, (const xmlChar*)tmp); + name = val; } else { fprintf(stderr,"WARNING: no name property in %s element\n", (const char *)node->name ); name = strdup("[undefined]"); @@ -7216,7 +7276,8 @@ tmp = xmlGetProp( node, (const xmlChar *)"url" ); if( tmp ) { - url = strdup((const char *)tmp); + char *val = fromXmlChar(ctx, (const xmlChar*)tmp); + url = val; } else { fprintf(stderr,"WARNING: no url property in %s element\n", (const char *)node->name ); url = strdup("[undefined]"); @@ -7488,7 +7549,8 @@ tmp = xmlGetProp( node, (const xmlChar *)"value" ); if( tmp ) { - value = strdup((const char *)tmp); + char *val = fromXmlChar(ctx, (const xmlChar*)tmp); + value = val; } else { fprintf(stderr,"WARNING: no value property in %s element\n", (const char *)node->name ); value = strdup("[undefined]"); @@ -8435,7 +8497,8 @@ tmp = xmlGetProp( node, (const xmlChar *)"url" ); if( tmp ) { - url = strdup((const char *)tmp); + char *val = fromXmlChar(ctx, (const xmlChar*)tmp); + url = val; } else { fprintf(stderr,"WARNING: no url property in %s element\n", (const char *)node->name ); url = strdup("[undefined]"); @@ -8443,7 +8506,8 @@ tmp = xmlGetProp( node, (const xmlChar *)"target" ); if( tmp ) { - target = strdup((const char *)tmp); + char *val = fromXmlChar(ctx, (const xmlChar*)tmp); + target = val; } else { fprintf(stderr,"WARNING: no target property in %s element\n", (const char *)node->name ); target = strdup("[undefined]"); @@ -8537,7 +8601,8 @@ tmp = xmlGetProp( node, (const xmlChar *)"label" ); if( tmp ) { - label = strdup((const char *)tmp); + char *val = fromXmlChar(ctx, (const xmlChar*)tmp); + label = val; } else { fprintf(stderr,"WARNING: no label property in %s element\n", (const char *)node->name ); label = strdup("[undefined]"); @@ -8554,7 +8619,8 @@ tmp = xmlGetProp( node, (const xmlChar *)"label" ); if( tmp ) { - label = strdup((const char *)tmp); + char *val = fromXmlChar(ctx, (const xmlChar*)tmp); + label = val; } else { fprintf(stderr,"WARNING: no label property in %s element\n", (const char *)node->name ); label = strdup("[undefined]"); @@ -8596,7 +8662,8 @@ tmp = xmlGetProp( node, (const xmlChar *)"name" ); if( tmp ) { - name = strdup((const char *)tmp); + char *val = fromXmlChar(ctx, (const xmlChar*)tmp); + name = val; } else { fprintf(stderr,"WARNING: no name property in %s element\n", (const char *)node->name ); name = strdup("[undefined]"); @@ -8899,7 +8966,8 @@ tmp = xmlGetProp( node, (const xmlChar *)"name" ); if( tmp ) { - name = strdup((const char *)tmp); + char *val = fromXmlChar(ctx, (const xmlChar*)tmp); + name = val; } else { fprintf(stderr,"WARNING: no name property in %s element\n", (const char *)node->name ); name = strdup("[undefined]"); diff -ur swfmill-0.2.12/src/gSWFWriteXML.cpp swfmill-0.2.12.enc/src/gSWFWriteXML.cpp --- swfmill-0.2.12/src/gSWFWriteXML.cpp 2007-01-25 20:59:55.000000000 +0900 +++ swfmill-0.2.12.enc/src/gSWFWriteXML.cpp 2008-01-24 18:11:50.000000000 +0900 @@ -3,9 +3,61 @@ #include "SWF.h" #include "base64.h" #include "string.h" +#include +#include namespace SWF { +xmlChar *toXmlChar(const Context *ctx, const char *from_str) { + if (ctx->convertEncoding) { + size_t len = strlen(from_str); + iconv_t cd = iconv_open("UTF-8", ctx->swf_encoding); + if (cd < 0) { + fprintf(stderr, "iconv_open failed.\n"); + return xmlCharStrdup(""); + } + + size_t buf_size = (len + 1) * 2; + char *dst; + for (;;) { + dst = new char[buf_size]; + size_t inbytesleft = len; + size_t outbytesleft = buf_size - 1; + char *pin = (char*)from_str; + char *pout = dst; + bool expandbuf = false; + + while (inbytesleft > 0) { + size_t r = iconv(cd, &pin, &inbytesleft, &pout, &outbytesleft); + if (r == (size_t)-1) { + if (errno == E2BIG) { + // buf_size shorten + expandbuf = true; + } else { + //bad input charctor + fprintf(stderr, "iconv failed: %s\n", from_str); + } + break; + } + } + if (expandbuf) { + delete[] dst; + iconv(cd, 0, 0, 0, 0); + buf_size *= 2; + continue; + } + *pout = '\0'; + break; + } + iconv_close(cd); + xmlChar *ret = xmlCharStrdup(dst); + delete[] dst; + return ret; + } else { + return xmlCharStrdup(from_str); + } +} + #define TMP_STRLEN 0xFF @@ -89,7 +141,8 @@ node = xmlNewChild( node, NULL, (const xmlChar *)"String", NULL ); if( value ) { - xmlSetProp( node, (const xmlChar *)"value", (const xmlChar *)value ); + xmlChar *xmlstr = toXmlChar(ctx, value); + xmlSetProp(node, (const xmlChar *)"value", xmlstr); } @@ -771,7 +824,8 @@ xmlSetProp( node, (const xmlChar *)"objectID", (const xmlChar *)&tmp ); if( name ) { - xmlSetProp( node, (const xmlChar *)"name", (const xmlChar *)name ); + xmlChar *xmlstr = toXmlChar(ctx, name); + xmlSetProp(node, (const xmlChar *)"name", xmlstr); } @@ -795,7 +849,8 @@ xmlSetProp( node, (const xmlChar *)"reg", (const xmlChar *)&tmp ); if( name ) { - xmlSetProp( node, (const xmlChar *)"name", (const xmlChar *)name ); + xmlChar *xmlstr = toXmlChar(ctx, name); + xmlSetProp(node, (const xmlChar *)"name", xmlstr); } @@ -3572,7 +3627,8 @@ if( hasName ) { if( name ) { - xmlSetProp( node, (const xmlChar *)"name", (const xmlChar *)name ); + xmlChar *xmlstr = toXmlChar(ctx, name); + xmlSetProp(node, (const xmlChar *)"name", xmlstr); } } @@ -3669,7 +3725,8 @@ if( hasName ) { if( name ) { - xmlSetProp( node, (const xmlChar *)"name", (const xmlChar *)name ); + xmlChar *xmlstr = toXmlChar(ctx, name); + xmlSetProp(node, (const xmlChar *)"name", xmlstr); } } @@ -3823,13 +3880,15 @@ } if( variableName ) { - xmlSetProp( node, (const xmlChar *)"variableName", (const xmlChar *)variableName ); + xmlChar *xmlstr = toXmlChar(ctx, variableName); + xmlSetProp(node, (const xmlChar *)"variableName", xmlstr); } if( hasText ) { if( initialText ) { - xmlSetProp( node, (const xmlChar *)"initialText", (const xmlChar *)initialText ); + xmlChar *xmlstr = toXmlChar(ctx, initialText); + xmlSetProp(node, (const xmlChar *)"initialText", xmlstr); } } @@ -3905,7 +3964,8 @@ if( hasText ) { if( initialText ) { - xmlSetProp( node, (const xmlChar *)"initialText", (const xmlChar *)initialText ); + xmlChar *xmlstr = toXmlChar(ctx, initialText); + xmlSetProp(node, (const xmlChar *)"initialText", xmlstr); } } @@ -3960,7 +4020,8 @@ node = xmlNewChild( node, NULL, (const xmlChar *)"FrameLabel", NULL ); if( label ) { - xmlSetProp( node, (const xmlChar *)"label", (const xmlChar *)label ); + xmlChar *xmlstr = toXmlChar(ctx, label); + xmlSetProp(node, (const xmlChar *)"label", xmlstr); } node2 = xmlNewChild( node, NULL, (const xmlChar *)"flags", NULL ); @@ -4099,7 +4160,8 @@ xmlSetProp( node, (const xmlChar *)"language", (const xmlChar *)&tmp ); if( name ) { - xmlSetProp( node, (const xmlChar *)"name", (const xmlChar *)name ); + xmlChar *xmlstr = toXmlChar(ctx, name); + xmlSetProp(node, (const xmlChar *)"name", xmlstr); } node2 = xmlNewChild( node, NULL, (const xmlChar *)"glyphs", NULL ); @@ -4435,7 +4497,8 @@ node = xmlNewChild( node, NULL, (const xmlChar *)"Import", NULL ); if( url ) { - xmlSetProp( node, (const xmlChar *)"url", (const xmlChar *)url ); + xmlChar *xmlstr = toXmlChar(ctx, url); + xmlSetProp(node, (const xmlChar *)"url", xmlstr); } { @@ -4688,7 +4751,8 @@ if( hasName ) { if( name ) { - xmlSetProp( node, (const xmlChar *)"name", (const xmlChar *)name ); + xmlChar *xmlstr = toXmlChar(ctx, name); + xmlSetProp(node, (const xmlChar *)"name", xmlstr); } } @@ -4829,7 +4893,8 @@ if( hasName ) { if( name ) { - xmlSetProp( node, (const xmlChar *)"name", (const xmlChar *)name ); + xmlChar *xmlstr = toXmlChar(ctx, name); + xmlSetProp(node, (const xmlChar *)"name", xmlstr); } } @@ -4914,7 +4979,8 @@ node = xmlNewChild( node, NULL, (const xmlChar *)"ImportAssets2", NULL ); if( url ) { - xmlSetProp( node, (const xmlChar *)"url", (const xmlChar *)url ); + xmlChar *xmlstr = toXmlChar(ctx, url); + xmlSetProp(node, (const xmlChar *)"url", xmlstr); } snprintf(tmp,TMP_STRLEN,"%i", reserved1); @@ -5126,7 +5192,8 @@ node = xmlNewChild( node, NULL, (const xmlChar *)"StackString", NULL ); if( value ) { - xmlSetProp( node, (const xmlChar *)"value", (const xmlChar *)value ); + xmlChar *xmlstr = toXmlChar(ctx, value); + xmlSetProp(node, (const xmlChar *)"value", xmlstr); } @@ -6770,11 +6837,13 @@ node = xmlNewChild( node, NULL, (const xmlChar *)"GetURL", NULL ); if( url ) { - xmlSetProp( node, (const xmlChar *)"url", (const xmlChar *)url ); + xmlChar *xmlstr = toXmlChar(ctx, url); + xmlSetProp(node, (const xmlChar *)"url", xmlstr); } if( target ) { - xmlSetProp( node, (const xmlChar *)"target", (const xmlChar *)target ); + xmlChar *xmlstr = toXmlChar(ctx, target); + xmlSetProp(node, (const xmlChar *)"target", xmlstr); } @@ -6872,7 +6941,8 @@ node = xmlNewChild( node, NULL, (const xmlChar *)"SetTarget", NULL ); if( label ) { - xmlSetProp( node, (const xmlChar *)"label", (const xmlChar *)label ); + xmlChar *xmlstr = toXmlChar(ctx, label); + xmlSetProp(node, (const xmlChar *)"label", xmlstr); } @@ -6893,7 +6963,8 @@ node = xmlNewChild( node, NULL, (const xmlChar *)"GotoLabel", NULL ); if( label ) { - xmlSetProp( node, (const xmlChar *)"label", (const xmlChar *)label ); + xmlChar *xmlstr = toXmlChar(ctx, label); + xmlSetProp(node, (const xmlChar *)"label", xmlstr); } @@ -6937,7 +7008,8 @@ node = xmlNewChild( node, NULL, (const xmlChar *)"DeclareFunction2", NULL ); if( name ) { - xmlSetProp( node, (const xmlChar *)"name", (const xmlChar *)name ); + xmlChar *xmlstr = toXmlChar(ctx, name); + xmlSetProp(node, (const xmlChar *)"name", xmlstr); } snprintf(tmp,TMP_STRLEN,"%i", argc); @@ -7148,7 +7220,8 @@ node = xmlNewChild( node, NULL, (const xmlChar *)"DeclareFunction", NULL ); if( name ) { - xmlSetProp( node, (const xmlChar *)"name", (const xmlChar *)name ); + xmlChar *xmlstr = toXmlChar(ctx, name); + xmlSetProp(node, (const xmlChar *)"name", xmlstr); } snprintf(tmp,TMP_STRLEN,"%i", argc); diff -ur swfmill-0.2.12/src/swfmill.cpp swfmill-0.2.12.enc/src/swfmill.cpp --- swfmill-0.2.12/src/swfmill.cpp 2006-07-21 19:44:26.000000000 +0900 +++ swfmill-0.2.12.enc/src/swfmill.cpp 2008-01-24 18:11:50.000000000 +0900 @@ -16,6 +16,7 @@ bool quiet = false; bool verbose = false; bool dump = false; +const char *swf_encoding = "UTF-8"; const char *internal_stylesheet = NULL; void usage() { @@ -59,6 +60,7 @@ " -v verbose output\n" " -V extra-verbose debugging output\n" " -d dump SWF data when loaded (for debugging)\n" + " -e specify text encoding in swf file. (default: UTF-8).\n" "\n" "E-mail bug reports to "PACKAGE_BUGREPORT"\n\n" ); @@ -117,6 +119,12 @@ ctx.debugTrace = verbose; ctx.quiet = quiet; +// setup encoding convertion. + if (strcmp(swf_encoding, "UTF-8")) { + ctx.convertEncoding = true; + ctx.swf_encoding = swf_encoding; + } + // treat input as SWF, produce XML if( (size = input.load( in_fp, &ctx, filesize )) != 0 ) { if( dump ) input.dump(); @@ -174,7 +182,13 @@ // setup context ctx.debugTrace = verbose; ctx.quiet = quiet; - + +// setup encoding convertion. + if (strcmp(swf_encoding, "UTF-8")) { + ctx.convertEncoding = true; + ctx.swf_encoding = swf_encoding; + } + { filename = std_in ? "-" : infile ; doc = xmlParseFile( filename ); @@ -210,7 +224,7 @@ } // treat input as XML, produce SWF - input.setXML( doc->xmlRootNode, NULL ); + input.setXML( doc->xmlRootNode, &ctx ); if( dump ) input.dump(); out_fp = std_out ? stdout : fopen( outfile, "wb" ); if( !out_fp ) { @@ -432,6 +446,15 @@ usage(); goto fail; break; + case 'e': + ++swallow; + if (i+swallow < argc) { + swf_encoding = argv[i+swallow]; + } else { + usage(); + goto fail; + } + break; default: fprintf(stderr,"ERROR: unknown option %c\n",argv[i][j]); usage();