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. C / C++ / MFC
  4. System Local and Percentage Symbol

System Local and Percentage Symbol

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 Posts 3 Posters 1 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.
  • O Offline
    O Offline
    orcun colak
    wrote on last edited by
    #1

    How can I get the position of percentage symbol and format a string ? E.g. 45% or %45 Thanks Orcun Colak

    A 1 Reply Last reply
    0
    • O orcun colak

      How can I get the position of percentage symbol and format a string ? E.g. 45% or %45 Thanks Orcun Colak

      A Offline
      A Offline
      AlexO
      wrote on last edited by
      #2

      char buffer[1024]; int n = 45; sprintf(buffer, "%%%d", n);

      O 1 Reply Last reply
      0
      • A AlexO

        char buffer[1024]; int n = 45; sprintf(buffer, "%%%d", n);

        O Offline
        O Offline
        orcun colak
        wrote on last edited by
        #3

        I was not clear. My mistake sorry. I wanted to format a percentage according to system settings but I do not know how to get system settings. For example in US percentage is formatted like 45% Somewhere else it is %45. How can I output the correct percentage according to system settings. Thanks Orcun Colak

        A 1 Reply Last reply
        0
        • O orcun colak

          I was not clear. My mistake sorry. I wanted to format a percentage according to system settings but I do not know how to get system settings. For example in US percentage is formatted like 45% Somewhere else it is %45. How can I output the correct percentage according to system settings. Thanks Orcun Colak

          A Offline
          A Offline
          Alvaro Mendez
          wrote on last edited by
          #4

          orcun colak wrote: For example in US percentage is formatted like 45% Somewhere else it is %45. Are you sure about this? Why is there no way to set this in the Control Panel? There's even no mention of a % symbol or position, nothing. The GetLocaleInfo API doesn't mention it either. It seems like the percent sign is universal and I would imagine that so is it's position. At any rate, if you're sure there's (weird) people out there who prefer to see it on the left, you may have to handle it yourself, which isn't too difficult. Regards, Alvaro


          Well done is better than well said. -- Benjamin Franklin (I actually prefer medium-well.)

          O 1 Reply Last reply
          0
          • A Alvaro Mendez

            orcun colak wrote: For example in US percentage is formatted like 45% Somewhere else it is %45. Are you sure about this? Why is there no way to set this in the Control Panel? There's even no mention of a % symbol or position, nothing. The GetLocaleInfo API doesn't mention it either. It seems like the percent sign is universal and I would imagine that so is it's position. At any rate, if you're sure there's (weird) people out there who prefer to see it on the left, you may have to handle it yourself, which isn't too difficult. Regards, Alvaro


            Well done is better than well said. -- Benjamin Franklin (I actually prefer medium-well.)

            O Offline
            O Offline
            orcun colak
            wrote on last edited by
            #5

            Actually I found this link in msdn http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vjref98/html/java.text.NumberFormat001.asp Scroll to getPercentInstance() method. Explanation of the method is : "Returns a percentage format for the current default locale." Therefore I assumed Number % format is not universal. Thanks for your help Orcun Colak

            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