We help IT Professionals succeed at work.

Unicode value \u00B7 for middle dot change on Unix server to "\267" character - very urgent.

karpra
karpra used Ask the Experts™
on
windows Unicode value \u00B7 for middle dot change on Unix server to "\267" character

In Java code the line used is as below.
private static String middleDotUtf = "\u00B7"; // unicode value hardcoded which is of two bytes
we test a check if its true then we take the second byte which is the middle dot character. but when we install the application on unix machine its values changes to below i have decoded the class file source and saw the value its changes. could you please explain why? that would be a great help.

private static String middleDotUtf = "\267";
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016
Commented:
>>windows Unicode value \u00B7 for middle dot change on Unix server to "\267" character

267 is just the octal code for 0xB7

Author

Commented:
Thanks a appretiate your quick help
i wanted the middle dot but i get " character instead when i read the binary files. One the local server i can see it but on our main unix server its does not work it comes as " any idea why i get " instead of middledot
if(str.charAt(i)=='•'){
              String Dot = "\u00b7";
             byte[] dot = Dot.getBytes("UTF-8");
              result[i] = dot[1];
 }

Author

Commented:
Also i have one more question does that server need some font to be installed?
Top Expert 2016

Commented:
>>but on our main unix server its does not work it comes as

Comes where -where are you viewing it? It would

a. have to support Unicode
b. have to be using a font that had the glyph for that character
Top Expert 2016

Commented:
Top Expert 2016

Commented:
Also, can you tell me what this prints?
System.out.println(System.getProperty("file.encoding"));

Open in new window

Author

Commented:
File.encoding is UTF-8.
Top Expert 2016

Commented:
OK that's good. What did you get when you ran the code from the link i posted?

Author

Commented:
the link which you pasted i run it and passed the argument as 00b7 then i got this out put
Checking on character ·
java.awt.Font[family=Agency FB,name=Agency FB,style=plain,size=1]

which is correct.
Top Expert 2016

Commented:
OK, if you use that font in a medium that can display UTF-8, then you should be OK

Author

Commented:
so you mean we are encoding it correctly? then when i decode the string i can see all the special characters displayed correctly except middle dot any specific reason on that unix server that stops only this special character. now when i read i get a " that mean that condition is not satisfied. What we are doing we are encoding that character string in to binary file and decoding it to read. it reads  correctly on one server and does not on other server. not sure why.
Top Expert 2016

Commented:
All that code we just ran - i trust it  WAS 'on that unix server'?

Author

Commented:
so is there a way i can confirm if this font is on that unix server please
Top Expert 2016

Commented:
You must run the code on that server
Mick BarryJava Developer
Top Expert 2010

Commented:
sounds like you're not explicitly specify the encoding on the server
you need to ensure the server vm is started up with UTF8 or it will use the platform default encoing which may be incorrect.
You shouldn't need to worry about the font in your case

java -Dfile.encoding=UTF8 ....

Author

Commented:
When i built the jar on windows it works and when i build the jar on linux then it thats where this character fails. and whats strange is only this middledot failes rest all characters works fine. any way i can check on lunux server that this middledot font is supported or not?
Top Expert 2016

Commented:
>>any way i can check on lunux server that this middledot font is supported or not?

I've already given you the code for that - you just ran it in the wrong place
Mick BarryJava Developer
Top Expert 2010

Commented:
> if(str.charAt(i)=='•'){

that line will also cause problem, should be using the encoded value of the character you are checking for.

Otherwise you have to ensure that the encoding ogf the file is UTF-8 and that you are using -encoding option when compiling

Mick BarryJava Developer
Top Expert 2010

Commented:
>  any way i can check on lunux server that this middledot font is supported or not?

you don't need to worry about fonts
Top Expert 2016

Commented:
If you're viewing the Unix server through a terminal, that terminal also needs to be able to support the character
Top Expert 2016

Commented:
>>that line will also cause problem

You don't need to worry about that - it isn't causing a problem
Top Expert 2016

Commented:
>>could you please explain why?

I did. At http:#33109422
Top Expert 2016

Commented:
:)