Author Topic: [HELP]cgs to mks unit convertor  (Read 5442 times)

0 Members and 1 Guest are viewing this topic.

Offline Dark Nebulae

  • Peasant
  • *
  • Posts: 117
  • Cookies: -79
  • Unleash the Hacker within you
    • View Profile
[HELP]cgs to mks unit convertor
« on: October 29, 2012, 02:05:50 pm »
I want to make a program that can convert cgs units into mks units and vice-versa.I am able to convert the magnitude but I don't know how to print the units (such as kg-1m3s-2 for the units of G).I tried it in Ruby,Python,C++ but in all those languages, I faced the same problem.Plz Help.
« Last Edit: October 29, 2012, 02:06:07 pm by Dark Nebulae »
Trust is like a piece of paper.Once it is crumbled,it can never be perfect.

Offline Deque

  • P.I.N.N.
  • Global Moderator
  • Overlord
  • *
  • Posts: 1203
  • Cookies: 518
  • Programmer, Malware Analyst
    • View Profile
Re: [HELP]cgs to mks unit convertor
« Reply #1 on: October 29, 2012, 05:07:33 pm »
Unicode is your friend. Have a look at superscripts with Unicode: https://en.wikipedia.org/wiki/Unicode_subscripts_and_superscripts

Java and Unicode: http://docs.oracle.com/javase/tutorial/i18n/text/unicode.html

In Java you can create a Unicode string like this:

Code: [Select]
String unicodeExample = new String("\u00ea" + "\u00f1" + "\u00fc");

Offline Dark Nebulae

  • Peasant
  • *
  • Posts: 117
  • Cookies: -79
  • Unleash the Hacker within you
    • View Profile
Re: [HELP]cgs to mks unit convertor
« Reply #2 on: November 09, 2012, 01:29:38 pm »
Thanks for your suggestion but I am not so advance in java.In fact,I am at  the very basic level in java. Can u plz post a code so that I can understand the working of unicode string or a example of what I require. It would be of great help.Thanks ;) ;) 
Your tutorial about wordlist generator is very good. +1 for u.
Trust is like a piece of paper.Once it is crumbled,it can never be perfect.

Offline Deque

  • P.I.N.N.
  • Global Moderator
  • Overlord
  • *
  • Posts: 1203
  • Cookies: 518
  • Programmer, Malware Analyst
    • View Profile
Re: [HELP]cgs to mks unit convertor
« Reply #3 on: November 09, 2012, 02:55:43 pm »
Where do you print the string? Console, GUI (if GUI which component)? Depending on that you might have other possibilities.

I.e.
A JLabel can use HTML tags, so you can easily write superscripts:

Code: (Java) [Select]
JLabel label = JLabel("kg<html><sup>-1</sup></html>");

Offline Dark Nebulae

  • Peasant
  • *
  • Posts: 117
  • Cookies: -79
  • Unleash the Hacker within you
    • View Profile
Re: [HELP]cgs to mks unit convertor
« Reply #4 on: November 09, 2012, 03:00:43 pm »
Where do you print the string? Console, GUI (if GUI which component)? Depending on that you might have other possibilities.

I.e.
A JLabel can use HTML tags, so you can easily write superscripts:

Code: (Java) [Select]
JLabel label = JLabel("kg<html><sup>-1</sup></html>");
I use Netbeans IDE.
Thanks,I'll try it.
Trust is like a piece of paper.Once it is crumbled,it can never be perfect.