Emilian Abadjiev wrote:
George Danchev wrote:
On 22 01 2003 16:19, Kliment Ognianov wrote:
  
Emilian Abadjiev wrote:
    
Dori da inicializiraneto na String-a ot Unicode na CP1251, to pri
kompilirane Java-ta 6te syzdade edin i sy6ti rezultaten class tyj kato
wytre6no si pazi String-owete w UCS-2.

Kak moga da smenia encoding-a w titlebar-a?
      

�������� � ����������� � � JVM-�� ��� ��� ���������� ����������, ���� ��� JVM 
������� �� ����������� ���������� (��� ���������� �������?). ������ ������� 
���� �� ������� �� ���� ��� ������ http://cyrcho.sf.net ��������... �� ������ 
������...
  
������� ��� � �������� JDK-�� ����������� Sun-����� 1.3.1, 1.4 i 1.4.1 � IBM-����� 1.3 � 1.4.
  
Nnnne znam, tuk smenih Unicode codes s normalni si kirilishki bukvi i
    

��� Unicode �������� ������ �������� �� ������ � ������� �� ������ ��������� 
���. � ������ �������� ������ �� �������� � ���� � ��� ��� ����� �� �������� 
��� ������ ...

  
sraboti .... ne vqrvam da e ot tipa na OSa: FreeBSD
    

����� ������� ����� �� ���� � �� ����� ��� �� � Sun Java 2 version =< 1.4 
;-).... � ���� ��� JVM (������������ � ����� ������) ������� �� FreeBSD 
(������� �� �?), �� ����� ����� ���� �� FreeBSD native ������ �� JavaSoft ��� 
... 
  
�������� �������� ��� ����� � � CP1251, �� ��� �� �������� ������� (JLabel). ���� � ����, ������ ���� �� ��������� �:
� �javac TestFrame.java ���javac -encoding ISO-8859-1 TestFrame.java �� ��������� ����������� � CP1251, ��� �� ��������� � ���������� ��������� (-encoding CP1251) �� ��������� ������ "?????????" � titlebar-a. ������ Java-�� � ��� �������� ���, ����� �� �� ���� �� ���� �� ����� ������ window's titlebar encoding-a ��� ������ � ������ �� �� ������ �� �������.
�������� ���� ����������� ���������� ������ �� ������ �� ������� �����������, ����� ������� "��������" �������� � titlebar-a. �� ��� �� �� ����� ����� "��������" � �� �� �����, �� ��� ��� � ������� ������� �� ��� ������. ����� �� � �������� �� ������� � IBM-����� JDK 1.4.

import javax.swing.JFrame;

import javax.swing.JLabel;

public class TestFrame {

��� static String title_1 = "�����";
��� static String title_2 = "\u0410\u0411\u0412\u0413\u0414";

��� public static void main(String[] args) throws Exception {
��� ��� System.out.println(title_1 + " " + title_2);

��� ��� JFrame frame = new JFrame();
��� ��� frame.setTitle(fixTitle(title_1) + " " + fixTitle(title_2));
��� ��� frame.setSize(300, 100);
��� ��� JLabel label = new JLabel(title_1 + " " + title_2);
��� ��� frame.getContentPane().add(label);
��� ��� frame.show();
��� }

��� public static String fixTitle(String title) {
��� ��� String osName;

��� ��� if ((osName = System.getProperty("os.name")) != null) {
��� ��� ��� if (osName.toLowerCase().indexOf("linux") != -1) {
��� ��� ��� ��� try {
��� ��� ��� ��� ��� return new String(title.getBytes("CP1251"), "ISO-8859-1");
��� ��� ��� ��� } catch (java.io.UnsupportedEncodingException e) {}
��� ��� ��� }
��� ��� }

��� ��� return title;

��� }

}
============================================================================ A mail-list of Linux Users Group - Bulgaria (bulgarian linuxers). http://www.linux-bulgaria.org - Hosted by Internet Group Ltd. - Stara Zagora To unsubscribe: http://www.linux-bulgaria.org/public/mail_list.html ============================================================================


Reply via email to