2

A text block which will show the volume name, colon, Directory character seperator. In english culture it will show C:\ and in japanese culture it will show C:'Yen'

View.XAML file:

<TextBlock Text="{Binding VolumeNameString, Mode=OneWay}"/>

ViewModel.cs file:

public string VolumeName
    {
        get
        {
            return m_volumeName;
        }

        private set
        {
            if (m_volumeName != value)
            {
                m_volumeName = value;
                OnPropertyChanged("VolumeNameString");
            }
        }
    }

public string VolumeNameString
    {
        get
        {
            return (this.VolumeName + ":" + System.IO.Path.DirectorySeparatorChar.ToString(CultureInfo.CurrentCulture));
        }
    }

The issue is in japanese culture, it is still showing C:\ and not showing C:'Yen'.
'Yen' is Yen symbol here. I tried with Japanese OS but the issue is still there.

Am I doing anything wrong here? Application is created on .NET 3.5.

Christoph Fink
  • 22,727
  • 9
  • 68
  • 113
  • I guess you might want to set the locale to `ja-JP` like this: `Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = "ja-JP";` – naota Jul 19 '14 at 10:39
  • @naota: I tried the same but its not working also. CultureInfo.CurrentCulture is working fine for date-time format but not working for DirectorySeperator because of same location 5C. – Paresh Modak Jul 19 '14 at 11:18

1 Answers1

1

How are you viewing the resulting string? If you are using Unicode, it will appear as backslash. Only if you are using a japanese character set, like shift-jis, will you see the "yen" symbol instead.

Here are the ascii table and the shift-jis table: http://en.wikipedia.org/wiki/Shift-JIS http://www.ascii-code.com/

Notice how backslash in ascii and yen in shift-jis are both at location 5C. So the seperator codepoint is actually the same, it's just the character set that makes it display differently.

ben
  • 341
  • 1
  • 4
  • Hi Ben, Yes it is Unicode. I thought that CultureInfo.CurrentCulture should handle it accordingly. But now I think Before displaying the path separator, It has to be encoded to Shift-jis from unicode. – Paresh Modak Jul 18 '14 at 12:53