Results 1 to 20 of 24
- 08-10-2010, 08:40 PM #1
Senior Member
- Join Date
- Oct 2008
- Posts
- 116
- Rep Power
- 0
- 08-10-2010, 11:12 PM #2
Senior Member
- Join Date
- Oct 2008
- Posts
- 116
- Rep Power
- 0
message = ( String ) input.readObject(); // when use this in textField in networking Apps Russian go to client from server without any coding additions, in case of files read/write what must do?
- 08-11-2010, 12:09 AM #3
Have you looked at the Charset class? It has encoder and decoder methods to convert bytes into Unicode characters.
- 08-11-2010, 11:32 AM #4
Senior Member
- Join Date
- Apr 2010
- Location
- Belgrade, Serbia
- Posts
- 278
- Rep Power
- 4
I don't know exactly what do you want but try to use setLocale method.
Syntax:
public void setLocale(java.util.Locale locale) {
}
Example: setLocale(new java.util.Locale("en", "US"));
- 08-11-2010, 11:42 AM #5
- 08-11-2010, 12:56 PM #6
Senior Member
- Join Date
- Oct 2008
- Posts
- 116
- Rep Power
- 0
what is default char set in Files/Streams?
- 08-11-2010, 01:54 PM #7
Senior Member
- Join Date
- Apr 2010
- Location
- Belgrade, Serbia
- Posts
- 278
- Rep Power
- 4
I think it is unicode.
Do you have problem with streams or you maybe have a problem with showing text in console.
I am using eclipse and when I want to use cyrillic characters then I go and find unicode option for text in eclipse's preferences. :cool:
Also my small java programs with cyrillic characters don't work good, without setting that preference in eclipse.Last edited by cselic; 08-11-2010 at 01:58 PM.
- 08-11-2010, 03:25 PM #8
What classes are you talking about?what is default char set in Files/Streams?
The API doc for the classes could tell you.
- 08-11-2010, 04:37 PM #9
Senior Member
- Join Date
- Oct 2008
- Posts
- 116
- Rep Power
- 0
My code is
Java Code:O n l i n e = A5B8 = O f f l i n e = 5 2 A5B8 = A w a y = 0 <5AB5 = D o N o t D i s t u r b = 5 15A?>:>8BL = N o t A v a i l a b l e = = I n v i s i b l e = 52848<K9 = E n d C a l l w i t h % s = G8BL @073>2>@ A % s = C a l l % s = 8BL % s = M i s s e d c a l l = >: = M i s s e d c a l l s = :0/ >2 = I n s t a n t m e s s a g e = '0B = I n s t a n t m e s s a g e s = '0BK public class mergerTxt { private Formatter output; public mergerTxt() { try { { output = new Formatter( "merger.txt" ); output.flush(); // flush output to send header information File file = new File( "us-skype.lang" ); // get file name File fileRu = new File( "ru-skype.lang" ); // get file name String result; // result from checking file String result2; // result from checking file String result3; // result from checking file int dot ; int dot2; // file does exist if ( file.exists() ) { Scanner fileInput = new Scanner( file ); // file scanner Scanner fileInputRu = new Scanner( fileRu ); // file scanner while ( fileInput.hasNextLine() ) { result = fileInput.nextLine(); // read a line from file result2 = fileInputRu.nextLine(); // read a line from file dot = result.lastIndexOf("="); dot2 = result2.lastIndexOf("="); result3 = result.substring(dot + 1) + " = " + result2.substring(dot2 + 1); output.format( "%s\n", result3 ); } // end while } // end if // TEXT FILES us-skype.lang sSTATUSMENU_CAPTION_ONLINE=Online sSTATUSMENU_CAPTION_OFFLINE=Offline sSTATUSMENU_CAPTION_AWAY=Away sSTATUSMENU_CAPTION_DND=Do Not Disturb sSTATUSMENU_CAPTION_NA=Not Available sSTATUSMENU_CAPTION_INVISIBLE=Invisible sREDBUTTON_HINT_HANGUP=End Call with %s sGREENBUTTON_HINT_CALL=Call %s sSTATUSPAGE_MISSEDCALLS_ONE=Missed call sSTATUSPAGE_MISSEDCALLS_MORE=Missed calls sSTATUSPAGE_MISSEDMSGS_ONE=Instant message sSTATUSPAGE_MISSEDMSGS_MORE=Instant messages .............................................................................. ============================================= ru-skype.lang sSTATUSMENU_CAPTION_ONLINE=В сети sSTATUSMENU_CAPTION_OFFLINE=Не в сети sSTATUSMENU_CAPTION_AWAY=Нет на месте sSTATUSMENU_CAPTION_DND=Не беспокоить sSTATUSMENU_CAPTION_NA=Недоступен sSTATUSMENU_CAPTION_INVISIBLE=Невидимый sREDBUTTON_HINT_HANGUP=Окончить разговор с %s sGREENBUTTON_HINT_CALL=Позвонить %s sSTATUSPAGE_MISSEDCALLS_ONE=Пропущенный звонок sSTATUSPAGE_MISSEDCALLS_MORE=Пропущенных звонка/ов sSTATUSPAGE_MISSEDMSGS_ONE=Чат sSTATUSPAGE_MISSEDMSGS_MORE=Чаты ...............................................................................
- 08-11-2010, 04:58 PM #10
Can you explain what the problem is?
Show what is output and also show what you want the output to look like.
- 08-11-2010, 06:17 PM #11
Senior Member
- Join Date
- Oct 2008
- Posts
- 116
- Rep Power
- 0
the input is the two xxxxx.lang files at the end[3306 lines each file identical but the other is in russian after equals sign in a line]. The output is the appended prior the code, and want this output appear UNDERSTANDABLE RUSSIAN words from second .lang file, so... how use char set in code in the middle above?
- 08-11-2010, 07:07 PM #12
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
- 08-11-2010, 08:56 PM #13
Senior Member
- Join Date
- Oct 2008
- Posts
- 116
- Rep Power
- 0
with InputStreamReaders how to read line by line the text files?
File file = new File( "us-skype.lang" ); // get file name
File fileRu = new File( "ru-skype.lang" ); // get file name
File file2 = new File( "skype.lang" ); // get file name
InputStreamReader reader = new InputStreamReader(new FileInputStream (file), "UTF-8");
InputStreamReader readerRu = new InputStreamReader(new FileInputStream (fileRu), "UTF-8");
OutputStreamWriter output = new OutputStreamWriter(new FileOutputStream(file2), "UTF-8");
..................?.................
..................?.................
- 08-11-2010, 09:21 PM #14
Senior Member
- Join Date
- Oct 2008
- Posts
- 116
- Rep Power
- 0
I make another try but same result english ok russian like prior:
Java Code:skype.lang O n l i n e = A5B8 = O f f l i n e = 5 2 A5B8 = A w a y = 0 <5AB5 = D o N o t D i s t u r b = 5 15A?>:>8BL = N o t A v a i l a b l e = = I n v i s i b l e = 52848<K9 = E n d C a l l w i t h % s = G8BL @073>2>@ A % s = C a l l % s = 8BL % s = M i s s e d c a l l = >: = M i s s e d c a l l s = :0/ >2 = I n s t a n t m e s s a g e = '0B = I n s t a n t m e s s a g e s = '0BK = Y o u c a n ' t a d d y o u r s e l f t o C o n t a c t s . = 5;L7O 4>1028BL A0<>3> A51O = C a l l d u r a t i o n = >ABL @073>2>@0 = % s i s c a l l i n g = 8B = C o n n e c t i n g . . . = O5<. . . = C a l l i n p r o g r e s s = 45B @073>2>@ = C a l l e n d e d = = N o a n s w e r = 5B >B25B0 = B u s y = OB public class mergerTxt { public mergerTxt() { try // wait for connection, get streams, read file { File file = new File( "us-skype.lang" ); // get file name File fileRu = new File( "ru-skype.lang" ); // get file name File file2 = new File( "skype.lang" ); // get file name BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream (file), "UTF-8")); BufferedReader readerRu = new BufferedReader(new InputStreamReader(new FileInputStream (fileRu), "UTF-8")); OutputStreamWriter output = new OutputStreamWriter(new FileOutputStream(file2), "UTF-8"); String result; // result from checking file String result2; // result from checking file String result3; // result from checking file int dot ; int dot2; int i=1; // file does exist if ( file.exists() ) { while ( i<3306 ) { //fileInput.hasNextLine() i++; result = reader.readLine(); // read a line from file result2 = readerRu.readLine(); // read a line from file dot = result.lastIndexOf("="); dot2 = result2.lastIndexOf("="); result3 = result.substring(dot + 1) + " = " + result2.substring(dot2 + 1); output.write( result3 + "\n" ); // output line of file } // end while } // end if else // file does not exist { result = file.getName() + " does not exist\n"; } // end else } // end try catch( IOException ioException ) { ioException.printStackTrace(); System.exit( 0 ); } // end catch finally { try { } // end try catch ( Exception ioException ) { ioException.printStackTrace(); System.exit( 0 ); } // end catch } // end finally } // end method runServer } // end class Server
- 08-11-2010, 10:06 PM #15
What is the output supposed to look like?
There are two input files. Both in key=value format.
The key values are both English.
The value values are in English in the us-... file
and in Russian in the ru-... file.
What is the output file supposed to look like given these three different fields: English keys, English values and Russian values?
What format are the input files in? Unicode or ASCII or ???
On my WinXP system I had to save the ru-... file in Unicode format to preserve the Russian characters. Saved as ASCII, all the Russian letters are ???s
- 08-11-2010, 10:23 PM #16
I get the following as the merged output using:
Java Code:BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream (file))); BufferedReader readerRu = new BufferedReader(new InputStreamReader(new FileInputStream (fileRu), "Unicode")); OutputStreamWriter output = new OutputStreamWriter(new FileOutputStream(file2), "Unicode");
Online = В сети
Offline = Не в сети
Away = Нет на месте
Do Not Disturb = Не беспокоить
Not Available = Недоступен
Invisible = Невидимый
End Call with %s = Окончить разговор с %s
Call %s = Позвонить %s
Missed call = Пропущенный звонок
Missed calls = Пропущенных звонка/ов
Instant message = Чат
Instant messages = Чаты
- 08-11-2010, 10:33 PM #17
Senior Member
- Join Date
- Oct 2008
- Posts
- 116
- Rep Power
- 0
OUTPUT:
English values = Russian values
English values = Russian values
English values = Russian values
English values = Russian values
In Notepad++ or/and win notepad,
how understand charset format, and how save russian char file to utf-8?
- 08-11-2010, 10:54 PM #18
Did you see my post#16?
- 08-12-2010, 08:20 AM #19
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
- 08-12-2010, 09:10 AM #20
Senior Member
- Join Date
- Apr 2010
- Location
- Belgrade, Serbia
- Posts
- 278
- Rep Power
- 4
lse123 as I told you earlier you must go to preferences and choose utf8 for console.
In eclipse for example is:
Preferences -> General -> Workspace -> TextFileEncoding -> Other.
In other choose UTF8.
I think that your code is good with cyrillic characters but they are not visible in command line of your IDE for Java.
This little example with russian characters works on my eclipse IDE for java:
class Russian.java
Java Code:import java.io.File; import java.io.FileReader; import java.io.BufferedReader; import java.io.IOException; public class Russian { public static void main(String[] args) { File filename = new File("russian.txt"); try { BufferedReader in = new BufferedReader(new FileReader(filename)); String line; while((line = in.readLine()) != null) { System.out.println(line); } } catch(IOException ex) { ex.printStackTrace(); System.exit(0); } } }
file: russian.txt
What IDE you are using? Eclipse, MotoDev, Netbeans or something else?Java Code:Уважаемый санек, эксперементы с очисткой ленты в противном случае приводят к сокращению срока службы ленты, повреждению стыков ленты и загрязнению околоконвейерного пространства, что в итоге выражается в значительных финансовых затратах предприятия. Так что сами решайте нормально это или нет. Уважаемый Лёха-мастер, работа лопатой- это тяжелый и неблагодарный труд, который весьма дорого обходится работодателю. Нормальный межсервисный срок для очистителя составляет 6 месяцев, а срок службы- три года. Так что рекомендую обратиться к профессионалам.
You can also try to write simple program with russian characters. Try to read file with russian characters and write it to new file.
If in new file there is also russian characters, then it is a problem with your IDE preferences.Last edited by cselic; 08-12-2010 at 09:13 AM.
Similar Threads
-
Convert avi, mpeg, wmv media files to .flv files in java code
By vinay1497 in forum New To JavaReplies: 8Last Post: 07-30-2010, 05:47 PM -
Problem with writing unicode characters in a file
By ze snow in forum New To JavaReplies: 1Last Post: 02-23-2010, 10:47 PM -
Problem displaying UNICODE characters on a JLabel
By lumpy in forum New To JavaReplies: 2Last Post: 02-15-2010, 06:49 AM -
Form Based Authentication fails with unicode characters
By davesquire in forum Java ServletReplies: 1Last Post: 09-25-2009, 06:00 PM -
writing and reading unicode characters from a file
By ranoosh in forum Advanced JavaReplies: 4Last Post: 09-28-2008, 04:34 AM


LinkBack URL
About LinkBacks


Bookmarks