Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Studio
  4. currency symbol is not consistent in Visual Studio

currency symbol is not consistent in Visual Studio

Scheduled Pinned Locked Moved Visual Studio
visual-studiodebuggingquestioncsharp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TimMackey
    wrote on last edited by
    #1

    I have the following code:

    System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("en-US");
    System.Threading.Thread.CurrentThread.CurrentCulture = ci;
    System.Threading.Thread.CurrentThread.CurrentUICulture = ci;
    Console.WriteLine("Currency symbol test {0:s} {1:c}", ci.NumberFormat.CurrencySymbol, 12.34M);
    System.Diagnostics.Debug.WriteLine("Currency symbol test {0:s} {1:c}", ci.NumberFormat.CurrencySymbol, 56.78M);

    When running the program from a Command window, the currency symbol (24 hex) is correctly displayed in both instances, as follows: Currency symbol test $ $12.34 When running the program from VS (2010) debugger, the currency symbol (A4 hex) is incorrectly displayed when writing to the VS output window pane, as follows: Currency symbol test $ ¤56.78 My Windows 7 Region and Language settings are English and United States. The Currency Symbol is dollar sign ($). How can I force Visual Studio to recognize the current locale and output the correct currency symbol in the output window pane?

    L M 2 Replies Last reply
    0
    • T TimMackey

      I have the following code:

      System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("en-US");
      System.Threading.Thread.CurrentThread.CurrentCulture = ci;
      System.Threading.Thread.CurrentThread.CurrentUICulture = ci;
      Console.WriteLine("Currency symbol test {0:s} {1:c}", ci.NumberFormat.CurrencySymbol, 12.34M);
      System.Diagnostics.Debug.WriteLine("Currency symbol test {0:s} {1:c}", ci.NumberFormat.CurrencySymbol, 56.78M);

      When running the program from a Command window, the currency symbol (24 hex) is correctly displayed in both instances, as follows: Currency symbol test $ $12.34 When running the program from VS (2010) debugger, the currency symbol (A4 hex) is incorrectly displayed when writing to the VS output window pane, as follows: Currency symbol test $ ¤56.78 My Windows 7 Region and Language settings are English and United States. The Currency Symbol is dollar sign ($). How can I force Visual Studio to recognize the current locale and output the correct currency symbol in the output window pane?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      It looks like Visual Studio is not using the region settings of your system but using the default symbol[^]. I would suggest you raise this with Microsoft.

      One of these days I'm going to think of a really clever signature.

      1 Reply Last reply
      0
      • T TimMackey

        I have the following code:

        System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("en-US");
        System.Threading.Thread.CurrentThread.CurrentCulture = ci;
        System.Threading.Thread.CurrentThread.CurrentUICulture = ci;
        Console.WriteLine("Currency symbol test {0:s} {1:c}", ci.NumberFormat.CurrencySymbol, 12.34M);
        System.Diagnostics.Debug.WriteLine("Currency symbol test {0:s} {1:c}", ci.NumberFormat.CurrencySymbol, 56.78M);

        When running the program from a Command window, the currency symbol (24 hex) is correctly displayed in both instances, as follows: Currency symbol test $ $12.34 When running the program from VS (2010) debugger, the currency symbol (A4 hex) is incorrectly displayed when writing to the VS output window pane, as follows: Currency symbol test $ ¤56.78 My Windows 7 Region and Language settings are English and United States. The Currency Symbol is dollar sign ($). How can I force Visual Studio to recognize the current locale and output the correct currency symbol in the output window pane?

        M Offline
        M Offline
        Matt T Heffron
        wrote on last edited by
        #3

        using .NET Reflector I checked what really is done and System.Diagnostics.Debug.WriteLine() explicitly uses CultureInfo.InvariantCulture for its internal call to string.Format(). If you really need the debug output to use some other culture, then you'll need to call string.Format() yourself.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups