eval { $w->AddText( $text ) }; if( $@ ) { for( map ord, split //, $text ) { eval { $w->AddCharacter( $_ ) }; if( $@ ) { $w->StartElementLiteral( 'char' ); $w->AddAttributeLiteral( '', ord => $_ ); $w->EndElement(); } } }