With Unicode you can program and accomplish many funny, cool and useful programs and tools as for instance, Abjad Calculator, Bubble Text Generator to write letters in circle, Flip Text Generator to write letters upside down, Google Transliteration to convert English names to Persian/Arabic, etc...
3. Character Sets
» ASCII
˃ The 128 most commonly-used characters are each
represented by a sequence of 7 bits known as the
character’s ASCII code.
˃ The characters include letters, digits, punctuation
marks, and nonprintable control characters such as
the backspace, tab, carriage return, etc.
» Unicode
˃ The Unicode standard defines underlying numeric
values for a huge set of 65,536 characters.
3
https://www.facebook.com/Oxus20
4. Unicode Tips
» Bubble Example
˃ OXUS20 => ⓄⓍⓊⓈ➁ⓞ
» Flip Example
˃ OXUS20 => 02snxo
» English Number to Persian
˃ 1234 => ۱۲۳۴
4
https://www.facebook.com/Oxus20
5. What is Abjad ?
» Every letter in the
Arabic alphabet has a
numerical
(Gematrical) value.
» A number of
calculations can be
made from this basis.
» These are referred to
as numerological
(Abjad) calculations.
5
https://www.facebook.com/Oxus20
10. public AbjadCalculator() {
// Background Customization
imgBackround = new ImageIcon(getClass().getResource("background.jpg"));
lblBackground = new JLabel(imgBackround);
add(lblBackground);
// Labels and TextFields Customization
lblInput = new JLabel("Type your name in Arabic/Persian:");
lblInput.setForeground(Color.white);
txtInput = new JTextField(";)"بسم هللا الرحمن الرحیم
txtInput.setHorizontalAlignment(JTextField.RIGHT);
lblOutput = new JLabel("Abjad calculation of your name:");
lblOutput.setForeground(Color.white);
txtOutput = new JTextField("786");
panelNorth = new JPanel();
panelNorth.setBackground(new Color(0, 153, 204));
panelNorth.setLayout(new GridLayout(3, 2));
panelNorth.add(lblInput);
panelNorth.add(txtInput);
panelNorth.add(lblOutput);
panelNorth.add(txtOutput);
add(panelNorth, BorderLayout.NORTH);
https://www.facebook.com/Oxus20
10
12. // Add action to calculation and exit buttons
public void actionPerformed(ActionEvent e) {
if (e.getSource() == btnCalculate) {
int total = 0;
String inputStr = txtInput.getText();
for (int i = 0; i < inputStr.length(); i++) {
total += Integer.parseInt(abjadKabir(inputStr.charAt(i)));
}
txtOutput.setText(String.valueOf(total));
}
if (e.getSource() == btnExit) {
System.exit(0);
}
}
12
https://www.facebook.com/Oxus20
14. Abjad Calculator in JAVA
(End of Source Code)
public static void main(String[] args) {
new AbjadCalculator();
}
}
14
https://www.facebook.com/Oxus20
15. Bubble Example in JAVA
Graphical User Interface
15
https://www.facebook.com/Oxus20
26. Flip Example in JAVA
(End of Source Code)
public static void main(String[] args) {
new Flip();
}
}
26
https://www.facebook.com/Oxus20
27. English Number to Persian in JAVA
Graphical User Interface
27
https://www.facebook.com/Oxus20
28. English Number to Persian in JAVA
Source Code
import
import
import
import
import
import
import
java.awt.BorderLayout;
java.awt.Color;
java.awt.GridLayout;
java.awt.event.ActionEvent;
java.awt.event.ActionListener;
java.awt.event.KeyEvent;
java.awt.event.KeyListener;
import
import
import
import
import
import
javax.swing.ImageIcon;
javax.swing.JButton;
javax.swing.JFrame;
javax.swing.JLabel;
javax.swing.JPanel;
javax.swing.JTextField;
public class PersianNumbers extends JFrame implements KeyListener {
// Declaring Components
private JLabel lblInput, lblOutput;
private JTextField txtInput, txtOutput;
private JButton btnExit;
private JPanel panelSouth, panelNorth;
private ImageIcon imgBackground;
private JLabel lblBackground;
28
https://www.facebook.com/Oxus20
29. public PersianNumbers() {
// Background Settings and Customizations
imgBackground = new ImageIcon(getClass().getResource("background.jpg"));
lblBackground = new JLabel(imgBackground);
add(lblBackground);
// Labels and TextFields Settings and Customizations
lblInput = new JLabel("Enter English Number :");
lblInput.setForeground(Color.white);
txtInput = new JTextField("0123456789");
txtInput.addKeyListener(this);
lblOutput = new JLabel("Result of Persion Number :");
lblOutput.setForeground(Color.white);
txtOutput = new JTextField("٠١٢٣٤٥٦٧٨٩");
panelNorth = new JPanel();
panelNorth.setBackground(new Color(0, 153, 204));
panelNorth.setLayout(new GridLayout(2, 2, 0, 2));
panelNorth.add(lblInput);
panelNorth.add(txtInput);
panelNorth.add(lblOutput);
panelNorth.add(txtOutput);
add(panelNorth, BorderLayout.NORTH);
29
https://www.facebook.com/Oxus20
30. // Exit Button Settings and Customizations
btnExit = new JButton("Exit");
btnExit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
panelSouth = new JPanel();
panelSouth.setBackground(new Color(0, 153, 204));
panelSouth.add(btnExit);
add(panelSouth, BorderLayout.SOUTH);
// JFrame Settings and Customizations
setUndecorated(true);
setSize(500, 317);
setLocationRelativeTo(null);
setVisible(true);
}
public void keyPressed(KeyEvent arg0) {
}
public void keyTyped(KeyEvent arg0) {
}
30
https://www.facebook.com/Oxus20
31. English Number to Persian in JAVA
End of Source Code
public void keyReleased(KeyEvent e) {
if (e.getSource() == txtInput) {
String input = txtInput.getText();
String change = input.replace('0', 'u0660').replace('1', 'u0661')
.replace('2', 'u0662').replace('3', 'u0663')
.replace('4', 'u0664').replace('5', 'u0665')
.replace('6', 'u0666').replace('7', 'u0667')
.replace('8', 'u0668').replace('9', 'u0669');
txtOutput.setText(change);
}
}
public static void main(String[] args) {
new PersianNumbers();
}
}
31
https://www.facebook.com/Oxus20
32. Tips
Simple String Methods
» charAt()
˃ The charAt(index) method returns the character at a specific index in
the string.
˃ The first character of a string is at index 0, the next at index 1, and so
on.
˃ The index argument must be greater than or equal to 0, and less than
the length of the string buffer.
» replaceAll()
˃ The String class also contains the replaceAll method for replacing and
splitting strings
˃ The replaceAll method replaces all matching substring.
32
https://www.facebook.com/Oxus20
33. Unicode
Further Works and Suggestions
» Transliteration
˃ English Name to Persian/Arabic
˃ Nahid Razaie =>
ناهید رضایی
» Google Transliteration
˃ Salam => سالم
˃ Ba OXUS20 Khush Amadid => 20
خوش آمدید به آکسیوس
33
https://www.facebook.com/Oxus20