Why does echo command in a csh script display multi-byte character string incorrectly?

Solution Verified - Updated -

Issue

  • The following csh scripts (script1.sh, script2.sh) are expected to work in exactly the same way.
     script1.sh (encoding:UTF8)
     +------------------------------------------------------------------+
 1   |#!/bin/csh -f                                                     |
 2   |################################################################  |
 3   |################################################################  |
 4   |################################################################  |
 ...     <repeat>
 60  |################################################################  |
 61  |################################################################  |
 62  |setenv LANG ja_JP.eucjp                                           |
 63  |################################################################  |
 64  |setenv LANG ja_JP.utf8                                            |
 65  |echo <multi-byte character string>                                |
     +------------------------------------------------------------------+
     script2.sh (encoding:UTF8)
     +------------------------------------------------------------------+
 1   |#!/bin/csh -f                                                     |
 2   |################################################################  |
 3   |################################################################  |
 4   |################################################################  |
 ...     <repeat>
 60  |################################################################  |
 61  |################################################################  |
 62  |setenv LANG ja_JP.eucjp                                           |
 63  |################################################################  |
 64  |################################################################  |
 65  |################################################################  |
 66  |################################################################  |
 67  |################################################################  |
 68  |################################################################  |
 69  |setenv LANG ja_JP.utf8                                            |
 70  |echo <multi-byte character string>                                |
     +------------------------------------------------------------------+
  • However, echo command in script2.sh incorrectly displays multi-byte character string, while script1.sh doesn't have such a problem.

Environment

  • Red Hat Enterprise Linux 5
  • Red Hat Enterprise Linux 6

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.