I think the answer goes to (for English speakers) from http://www.sql.ru/forum/1167615/java-jacob-rabota-s-kirillicey:
Macro A2W converts data from ANSI encoding in Windows Wide char. Hence
the conclusion, the input line should contain data in ANSI encoding
Windows (probably in 1251), but not in UTF8 (as is customary in Java).
Authors JACOB course little monsters that have not made the
conversion from UTF8 (adopted in Java) in Wide char. But I think the
national names in COM not so common. including I would like to try a
hand in Java to convert a string of UTF in 1251. It is clear that work
is only on Windows, where as ANSI encoding is 1251, ie Default
characterset = Russian
Originally in Russian:
Макрос A2W преобразует данные из ANSI кодировки Windows в Wide char.
Отсюда вывод, входные строка должна содержать данные в ANSI кодировки
Windows (скорее всего 1251), а НЕ в UTF8 (как принято в Java).
Авторы JACOB конечно немного уроды, что НЕ сделали преобразование из
UTF8 (принятой в Java) в Wide char. Но, думаю, национальные имена в
COM не так часто встречаются.
Т.ч. я бы попробывал просто руками в Java преобразовать строку из UTF
в 1251. Понятное дело, что работать будет только на Windows, где в
качестве ANSI кодировки стоит 1251, т.е. Default characterset =
Russian.
So, Java, by default, uses UTF-8, but Windows, hence the Jakob, uses cp1251. So convert the username, if Character.UnicodeBlock.CYRILLIC
then convert from UTF-8
to cp1251
.
Disclaimer, I'm unsure how good the Google translators translated the page...
Update, using UnicodeBlock to determine character type, see http://docs.oracle.com/javase/7/docs/api/java/lang/Character.UnicodeBlock.html for more information on UnicodeBlocks
//XXX over simplification, for it can also be CJK (Chinese Japanese Korean) or other...
public String hasCyrillicCharacters(final String text){
final char[] cc = text.toCharArray();
for (char c : cc) {
if (UnicodeBlock.CYRILLIC == UnicodeBlock.of(c)) {
return true;
}
}
return false;
}