-1

I have a unix script which calls java jar and gives some encrypted text (doesn't have any special character) as input. Java code decrypts it and then sends the decrypted message to database.

But sometimes special characters (à,ē) are given as inputs. So they are encrypted and sent to jar file. So far so good, but when we print the decrypted message,the spl characters are getting converted to question marks. I tried printing some special characters directly. They are also getting converted to question marks when I ran the Unix script manually. Output is junk characters instead of question marks or special characters.

When I try to put some logs like this LOGGER.info("áéróspåcê") it is getting converted to ??r?sp?c? when the script is running through crontab whereas "áéróspåcê" is getting converted to áéróspÃ¥cê when I trigger the script manually.

halfer
  • 19,824
  • 17
  • 99
  • 186
  • Please read [Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers?](//meta.stackoverflow.com/q/326569) - the summary is that this is not an ideal way to address volunteers, and is probably counterproductive to obtaining answers. Please refrain from adding this to your questions. – halfer Oct 12 '18 at 09:39

2 Answers2

1

The display output is determined by LOCALE and the fonts available in the terminal. Furthermore, while Java utilizes UTF, depending upon how this encrypted text is presented, there is no guarantee the data is presented as UTF.

You can try at your unix prompt the command locale, and especially LANG and potentially LC_ALL.

$ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_ALL=

With UTF-8 and the correct fonts for the terminal, it will display properly.

However, there could still be issues with the way the encrypted text is being presented to the java program, which could cause other issues.

Then, when you get to the database, the database must also support multi-byte characters.

KevinO
  • 4,303
  • 4
  • 27
  • 36
  • how to make crontab process output same as ./scriptname.sh 's output. for me ./scriptname.sh is giving exact output but crontab isn't. ./scriptname.sh 's output is àbùsstând whereas crontab's output is ??b??sst??nd – sashank sekhar Oct 16 '18 at 05:39
  • @sashanksekhar, the crontab uses a different environment. [Where can I set environment variables that crontab will use](https://stackoverflow.com/questions/2229825/where-can-i-set-environment-variables-that-crontab-will-use) gives some information. However, you would probably be better served by asking a new question and providing additional details. – KevinO Oct 16 '18 at 14:04
0

I'm afraid the windows console does not support special characters how ever this post might me related to this issue How to use unicode characters in Windows command line?

SamHoque
  • 2,978
  • 2
  • 13
  • 43