Viewing 14 replies - 1 through 14 (of 14 total)
  • The problem is that USPS has started to send the weird characters and they don`t encode them properly.
    Below is a fix that should work.

    Edit: usps_20.php
    Find:

    /**
      * USPS seems to be not able to encode their own XML appropriately
      * This function is used to fix their mistakes.
      * @author Greg Gullett (greg@ecsquest.com)
      * @since 2.0
      * @param string $response Reference to the $response string
      */
     function _clean_response( &$response ) {
      $bad_encoding = array( "<sup>&", ";</sup>" );
      $good_encoding = array( "<sup>","</sup>" );
      $response = str_replace( $bad_encoding, $good_encoding, $response );
     }

    Replace with:

    /**
      * USPS seems to be not able to encode their own XML appropriately
      * This function is used to fix their mistakes.
      * @author Greg Gullett (greg@ecsquest.com)
      * @since 2.0
      * @param string $response Reference to the $response string
      */
     function _clean_response( &$response ) {
     $response = str_replace('<sup>®</sup>',"",$response);
     $response = str_replace('<sup>™</sup>',"",$response);
     }
    Thread Starter jmessick9

    (@jmessick9)

    That did not work but atleast I know where it is at. This is what I have:

    function _clean_response( &$response ) {
    		$bad_encoding = array( "<sup>&", ";</sup>" );
    		$good_encoding = array( "<sup>","</sup>" );
    		$response = str_replace( $bad_encoding, $good_encoding, $response );
    	}
    Thread Starter jmessick9

    (@jmessick9)

    it didnt post the code correctly… hmm

    Here is the code on Pastebin:

    http://pastebin.com/qaJzkArw

    Thread Starter jmessick9

    (@jmessick9)

    This worked: Just in case someone needs it.

    function _clean_response( &$response ) {
    $bad_encoding = array( "& amp;lt;sup& amp;gt;", ";& amp;lt;/sup& amp;gt;" );
    $good_encoding = array( "<sup>", "</sup>" );
    $response = str_replace( $bad_encoding, $good_encoding, $response );

    remove the Space after the & above.

    Thanks.

    Not sure why, but I have this same issue and the code above doesn’t work for me. I agree that it should work and I’ve tried a few different variations. URL is rubyslube.com

    Has anybody else found any other place in the files for WP e-Commerce 3.8.12.1 where the original encoding might avoid being replaced?

    It’s also possible that it’s some sort of caching issue where I’m just not seeing the results of the change (I haven’t been able to get it to change at all, which seems odd since I would expect *something* to happen), but I’ve tried from multiple devices and it’s still showing me:

    Standard Post<sup>®</sup> $5.60
    First-Class Mail $3.60
    Priority Mail 1-Day<sup>™</sup> $5.60
    Priority Mail Express 2-Day<sup>™</sup> $16.05

    Actually, it’s not even showing it as well as here… Maybe a document encoding issue?

    Hmm, adding htmlspecialchars_decode() as a wrapper for str_replace( $bad_encoding, $good_encoding, $response ); does get it to look like it does above, but I can’t get it to remove or parse the <sup> as html.

    Thx to jmessick9
    The correction you posted worked very nicely

    The “better” way of doing it is to replace that function with this one:

    function _clean_response( &$response ) {
    	$response = html_entity_decode( html_entity_decode( $response ) );
    }

    Yes I had this problem and the function from misulicus fixed it.

    Thanks.

    Hmmm none of these fixes are working for me.. any other ideas on how I can fix this error? I am still seeing:

    & lt;sup& gt;& #8482;& lt;/sup& gt; (minus the spaces of course)

    I’m having the same issues as benarobinson. Has anyone had any new ideas? I have tried all that are shown here.

    Benarobinson did you ever find a solution?

    Thanks for any help,
    Alfred

    Jessica

    (@jessx62)

    I’m also looking for a fix to

    <sup>™</sup>

    being displayed with the USPS shipping options.

    Mihai Joldis

    (@misulicus)

    Try replacing the _clean_response function in USPS with this:

    function _clean_response( &$response ) {
    		$response = str_replace('<sup>®</sup>', '&reg;', $response);
    		$response = str_replace('<sup>™</sup>', '&trade;', $response);
    		$response = str_replace('<sup>®</sup>', '&reg;', $response);
    		$response = wp_specialchars_decode( wp_specialchars_decode( $response ) );
    		return $response;
    	}

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘USPS xml style wierd char’ is closed to new replies.