0
I have the following situation, work with the software A of vehicle sales, in it has the opportunity to sell and this has a media (as the customer learned the opportunity), in addition to the store opportunities the software A receives information from a vehicle website, this sends us the media information encoding different from the media of the software A, so this is saved in the database with strange characters, Referral would look something like: Indicaá$Á&o.
The site sends something like:
header("Content-Type: text/html; charset=utf-8");
...
$cliente = new client("http://999.999.999.999/WebService", false, $host, $porta, $usuario, $senha);
$chave_json = '[{ "chaveIntegracao" : "var1_",
"valor" : "'.$_POST["var1"].'"},
{"chaveIntegracao" : "var2_",
"valor" : "'.$_POST["var2"].'"},
{"chaveIntegracao" : "var3_",
"valor" : "'.$_POST["var3"].'"},
{"chaveIntegracao" : "var4_",
"valor" : "'.$_POST["var4"].'"
}]';
$dados[interfaceJson] = $chave_json;
$result = $cliente->call('criarEvento', $dados, 'http://.../', 'http://.../');
Is there any way to take the strange code and convert, without having to treat every possibility of strange character ?
//transforma qualquer encoding em UTF-8
CastEncoding(vo.getMidia(),"UTF-8");
How are you reading the information coming from this external site? Are they coming as byte or as string? Ideally, this kind of thing has to be done on arrival, before bytes become string. After that turned, it would be hell to undo... Please post the code snippet that reads this entry (I imagine you must be creating a
Reader
somewhere without specifying the encoding, I’m sure?).– mgibsonbr
Related: "The Absolute Minimum That Every Software Developer Absolutely, Positively Needs to Know About Unicode AND Character Sets (No Excuses!)"
– mgibsonbr
@mgibsonbr The site sends a JSON with the information, but I’ll ask them to fix it, then I’ll do an UPDATE in the bank, I don’t have much choice, thanks for the help.
– Tiago Oliveira de Freitas
Blz, but how do you get this JSON? How is the Java code that reads this? Even if they don’t correct on their side, you can still get the right data if you know which is the encoding of this JSON.
– mgibsonbr
@mgibsonbr This integration is not with me, I only work with integrated data, I will inform myself better and give you feedback.
– Tiago Oliveira de Freitas
@mgibsonbr I updated the question, this is the information that the site sends us, we receive with Web Service.
– Tiago Oliveira de Freitas
Are you sure the mistake is on their side? I think the error is on your side, but if you don’t show your Java code there’s no way I can help you...
– mgibsonbr