I am using Linux. I think you have a problem with the Windows terminal, which is notorious for only displaying a small range of characters. Maybe it is not set to accept Cyrillic writing. You are probably not using a computer with Russian as its default language. Try this instead of the print call in line 20:-java PhraseOMatic
Всё, что вам нужно, - это 30000-футовый распределённый выход из положения
That's a pleasureRich McStone wrote:Thanks for replying!
Please show us exactly what code you used with option pane and explain what went wrong.. . . I tried to use your new argument for printing phrase, but it didn't resolve the problem.
You oughtn't to have that problem with Java5, nor with Windows® if you have Russian locale set. You may need to dig deeper to find the problem. Try the following code unchanged:-This will tell you where the numbers come from. You should get this sort of output:-I'm using J2SE Development Kit 5.0 Update 15, which is old version. If I update it to newest version, can it resolve the problem?
Now change the code to read this:-You should get the same output. If you get anything different with either version please tell us.javac RussianLetters.java
java RussianLetters
0x0430 = 'а' 0x0431 = 'б' 0x0432 = 'в' 0x0433 = 'г' 0x0434 = 'д'
0x0435 = 'е' 0x0436 = 'ж' 0x0437 = 'з' 0x0438 = 'и' 0x0439 = 'й'
0x043a = 'к' 0x043b = 'л' 0x043c = 'м' 0x043d = 'н' 0x043e = 'о'
0x043f = 'п' 0x0440 = 'р' 0x0441 = 'с' 0x0442 = 'т' 0x0443 = 'у'
0x0444 = 'ф' 0x0445 = 'х' 0x0446 = 'ц' 0x0447 = 'ч' 0x0448 = 'ш'
0x0449 = 'щ' 0x044a = 'ъ' 0x044b = 'ы' 0x044c = 'ь' 0x044d = 'э'
0x044e = 'ю' 0x044f = 'я'
Please show us exactly what you used...
...explain what went wrong.
You should get the same output. If you get anything different with either version please tell us.
B:\Users\Desktop>javac RussianLetters2.java
RussianLetters2.java:5: unclosed character literal
for (char c = '╨░'; c <= '╤П'; c++)
^
RussianLetters2.java:5: illegal character: \176
for (char c = '╨░'; c <= '╤П'; c++)
^
RussianLetters2.java:5: unclosed character literal
for (char c = '╨░'; c <= '╤П'; c++)
^
RussianLetters2.java:5: unclosed character literal
for (char c = '╨░'; c <= '╤П'; c++)
^
RussianLetters2.java:5: unclosed character literal
for (char c = '╨░'; c <= '╤П'; c++)
^
RussianLetters2.java:10: illegal start of expression
}
^
6 errors
B:\Users\Desktop>java PhraseOMatic
Р?С?С?, С?С?Р? Р?Р°Р? Р?С?Р?Р?Р?, - С?С?Р? Р?Р° Р?С?Р?Р?Р?Р? Р?Р?Р?-С?Р?С?Р?Р?Р?
Р?Р?РёР№ С?Р°С?РїС?Р?Р?Р?Р?С?Р?Р?С?Р№ С?РёРї С?С?С?С?РєС?С?С?С?
All things are lawful, but not all things are profitable.
...and what about your editor? What are you using and can you find its encoding?
Campbell wrote:Also please tell us what the output from chcp is.
Rich wrote:The current code page:866
All things are lawful, but not all things are profitable.
System.out.printf("Всё, что вам нужно, - это %s%n", phrase);
That is because printf automatically uses your default Locale. If that doesn't work, try
System.out.printf(new java.util.Locale("RU", "ru"), "Всё, что вам нужно, - это %s%n", phrase);
B:\Users\Desktop>java PhraseOMatic
Всё, что вам нужно, - это Exception in thread "main" java.util.MissingFormatArgu
mentException: Format specifier '%s'
at java.util.Formatter.format(Unknown Source)
at java.io.PrintStream.format(Unknown Source)
at java.io.PrintStream.printf(Unknown Source)
at PhraseOMatic.main(PhraseOMatic.java:13)
But why is OP getting the compiler errors in this post?
You shouldn't get such an error if you wrote the printf call correctly. There should be one object after the ", and what I wrote shouldn't cause that Exception.Rich McStone wrote:. . . But I didn't use %s%n because it caused error:
. . .B:\Users\Desktop>java PhraseOMatic
Всё, что вам нужно, - это Exception in thread "main" java.util.MissingFormatArgu
mentException: Format specifier '%s'
. . .
Paper jam tastes about as you would expect. Try some on this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|