Max
Max

Reputation: 1334

Java Special Character Handling

I need to send a string to server. That string is having some special characters.

Example,

String abc = "ABC Farmacéutica Corporation";

When I am sending it, It is converted into, ABC Farmace@utica Corporation.

I Tried using UTF-8 encoding. it is giving output as ABC+Farmac%C3%A9utica+Corporation

please suggest me how to convert the data in java side.

Upvotes: 1

Views: 2481

Answers (1)

Jon Skeet
Jon Skeet

Reputation: 1504182

It entirely depends on how the server is set up to receive the string in the first place. Your second example is applying URL-encoding using UTF-8 where required, by the look of things. That might be appropriate - or it might not.

If the data is within XML, for example, you shouldn't need to do anything special - whatever XML API you use should handle all of this transparently.

If you can give more details about the protocol you're using to talk to the server, we may be able to help more.

Upvotes: 1

Related Questions