Versão atual:

*** Warning (DecodeUtf8) Invalid conversion from utf-8 to cp1252

Estou obtendo este erro de DECODEUTF8 na console ao tentar usar a função DECODEUTF8() pra converter o JSON retornado pela função FWREST. Isso ocorre em casos MUITO específicos, mas não consigo identificar qual seria o caracter que está causando o problema, ele aparece uma figura de um losango com uma interrogação no meio no json retornado... também tentei DECODEUTF16() e nada. Não achei documentação a respeito, alguém sabe quais seriam os caracteres a serem retirados de uma string pra validar no DECODEUTF8? Daí eu faria um replace na string antes de submeter à conversão.

Abaixo 2 exemplos de JSON que quando submetidos à função DECODEUTF8, o primeiro funciona e outro é o que dá o erro:

Exemplo de JSON que funciona normalmente quando submetido à DECODEUTF8

{"id":42505740,"accountName":"BRAMRCIO","marketPlaceId":"4584253","marketPlaceNumber":"4584253","marketPlace":"ME","createdAt":"2021-05-21T12:19:53Z","paymentDate":"2021-05-21T12:23:24Z","cancelDate":"2021-05-27T20:07:12Z","cancellationOrigin":"ORIGIN_MARKETPLACE","transmissionStatus":"OK","status":"CANCELED","marketPlaceUrl":"https://www.mercadolivre.com.br/vendas/4584224253/detalhe","marketPlaceShipmentStatus":"delivered","invoice":{"accessKey":"352105608548330001440000745111712135221","series":"004","number":"74511","date":"2021-05-24T10:10:00Z","cfop":"5910"},"marketPlaceStatus":"cancelled","discount":0,"freight":0,"sellerFreight":22.95,"interestValue":0,"gross":151.81,"total":151.81,"shipping":{"city":"Santo André","state":"SP","stateNameNormalized":"São Paulo","country":"Brasil","countryAcronymNormalized":"BR","countryNameNormalized":"BRASIL","address":"Rua Bera 963","number":"63","neighborhood":"Parque Erasmo Assunção","street":"Rua Jorge Beretta","comment":"Bloco 08 Ap 71","zipCode":"09271400","receiverName":"Adauto Oliveira","promisedShippingTime":"2021-05-25T03:00:00Z"},"billingAddress":{"city":"Santo André","state":"SP","stateNameNormalized":"São Paulo","country":"Brasil","countryAcronymNormalized":"BR","countryNameNormalized":"BRASIL","number":"963","neighborhood":"Parque Assunção","street":"rua a","comment":"BL 08, Ap 71","zipCode":"0900","shipmentUserName":"Ao Olra","shipmentUserDocument":"28824","shipmentUserDocumentType":"CPF"},"anymarketAddress":{"country":"Brasil","state":"São Paulo","stateAcronymNormalized":"SP","city":"Santo André","zipCode":"09271400","neighborhood":"Parque Assunção","address":"Rua Jorge 963","street":"Rua Jorge ","number":"963","comment":"Bloco 08 Ap 71","receiverName":"Ado Oa","promisedShippingTime":"2021-05-25T03:00:00Z"},"buyer":{"marketPlaceId":"41953473","name":"Ea Ribeiro","email":"erir.7f8wr1+2-ogq2tqnbsgi2deobz@mail.mercadolivre.com","document":"2824","documentType":"CPF","phone":"11999","cellPhone":"119699","documentNumberNormalized":"2824"},"tracking":{"number":"MEL000031631","carrier":"MEL Distribution","date":"2021-05-25T05:47:02Z","shippedDate":"2021-05-25T05:47:02Z"},"payments":[{"method":"pix","status":"refunded","value":151.81,"installments":1,"marketplaceId":"14977605","paymentMethodNormalized":"PIX","paymentDetailNormalized":"PIX","gatewayFee":2.92,"marketplaceFee":12.26}],"items":[{"product":{"id":254898,"title":"Kit Alto-falante B3x57x 5x7\" + B3x50x 5\" 200W Rms + Presente"},"sku":{"id":13603883,"title":"Kit Alto-falante B3x57x 5x7\" + B3x50x 5\" 200W Rms + Presente","partnerId":"9T9400K101"},"amount":1,"unit":151.81,"gross":151.81,"total":151.81,"discount":0,"shippings":[{"id":145007934,"shippingtype":"me2 - Prioritário","shippingCarrierNormalized":"UNKNOWN","shippingCarrierTypeNormalized":"UNKNOWN"}],"idInMarketPlace":"MLB1235251140","marketPlaceId":"4584224253","orderItemId":46191454,"officialStoreId":"781","officialStoreName":"ee","listingType":"gold_special","stocks":[{"stockLocalId":6844,"amount":1,"stockName":"Estoque Físico"}]}],"deliverStatus":"UNKNOWN","idAccount":88,"fulfillment":false,"shippingOptionId":"1067786","shippingId":"40592707","metadata":{"needInvoiceXML":"true"},"documentIntermediator":"03007331000141","intermediateRegistrationId":"426819","documentPaymentInstitution":"1"}"

Este é o JSON que não funciona:

{"id":31762397,"accountName":"BRMRCIO","marketPlaceId":"42885106","marketPlaceNumber":"4288106","marketPlace":"ME","createdAt":"2021-01-08T17:45:17Z","paymentDate":"2021-01-08T17:46:02Z","transmissionStatus":"OK","status":"CONCLUDED","marketPlaceUrl":"https://www.mercadolivre.com.br/vendas/428106/detalhe","marketPlaceShipmentStatus":"delivered","invoice":{"accessKey":"352101603000141550040000716481100301365","series":"004","number":"718","date":"2021-01-11T09:55:00Z","cfop":"6910"},"marketPlaceStatus":"paid","discount":0,"freight":0,"sellerFreight":31.95,"interestValue":0,"gross":439.9,"total":439.9,"shipping":{"city":"Salvador","state":"BA","stateNameNormalized":"Bahia","country":"Brasil","countryAcronymNormalized":"BR","countryNameNormalized":"BRASIL","address":"Rua Mário de 5","number":"5","neighborhood":"Caixa d'�gua","street":"Rua Mário de ","comment":"Casa, em frente ao muro do .","zipCode":"40330","receiverName":"Guimarães","receiverPhone":"715095","promisedShippingTime":"2021-01-14T03:00:00Z"},"billingAddress":{"city":"Salvador","state":"BA","stateNameNormalized":"Bahia","country":"Brasil","countryAcronymNormalized":"BR","countryNameNormalized":"BRASIL","number":"5","neighborhood":"Caixa D'Ã�gua","street":"Manoel ","comment":"Casa, Em Frente Ao Muro","zipCode":"40","shipmentUserName":"Guimarães","shipmentUserDocument":"037991","shipmentUserDocumentType":"CPF"},"anymarketAddress":{"country":"Brasil","state":"Bahia","stateAcronymNormalized":"BA","city":"Salvador","zipCode":"400","neighborhood":"Caixa d'�gua","address":"Rua Mário 5","street":"Rua Mário de ","number":"5","comment":"Casa, em frente ao muro.","receiverName":"Guimarães","promisedShippingTime":"2021-01-14T03:00:00Z"},"buyer":{"marketPlaceId":"93539","name":"Guimarães","email":"v.900b2y+2-ogqzdqobwgq2tcnbr@mail.mercadolivre.com","document":"03560","documentType":"CPF","phone":"715","documentNumberNormalized":"00"},"tracking":{"number":"40001","carrier":"FedEx Normal","date":"2021-01-12T05:37:11Z","shippedDate":"2021-01-12T05:37:11Z"},"payments":[{"method":"visa","status":"approved","value":439.9,"installments":4,"marketplaceId":"129776","paymentMethodNormalized":"CARTÃO DE CRÉDITO","paymentDetailNormalized":"VISA","gatewayFee":13.84,"marketplaceFee":52.14}],"items":[{"product":{"id":23672763,"title":"12-D4 12\" 500WRMS + Presente"},"sku":{"id":13082590,"title":"Alto-Falante UXP 12-D4 Subwoofer 12\" 500WRMS Bravox + Presente","partnerId":"9T7011K085"},"amount":1,"unit":439.9,"gross":439.9,"total":439.9,"discount":0,"shippings":[{"id":1166,"shippingtype":"me2 - Coleta Normal","shippingCarrierNormalized":"UNKNOWN","shippingCarrierTypeNormalized":"UNKNOWN"}],"idInMarketPlace":"MLB12445","marketPlaceId":"42886","orderItemId":34232,"officialStoreId":"1","officialStoreName":"d","listingType":"gold_pro","stocks":[{"stockLocalId":6844,"amount":1,"stockName":"Estoque Físico"}]}],"deliverStatus":"UNKNOWN","idAccount":8158,"fulfillment":false,"shippingOptionId":"1675311211","shippingId":"4033318","metadata":{"needInvoiceXML":"true"}}"

Versões (2):

Ver a versão formatada

*** Warning (DecodeUtf8) Invalid conversion from utf-8 to cp1252

Comentário

new question