Hi all,
I hope someone knows the answer to this issue!
I've got an application in
Java which calls another app via a callable statement, passing various parameters across. One of these parameters is a buffer containing transaction information.
Now we're working on an Arabic proof of concept, and when I create this buffer containing both Arabic, Latin and numeric data, the order of the
string is messed up.
E.g.
The data may be:
I
AED
17
شارة النقاط
1.7
101010
Test seventeen
17D
This appears in the buffer (with some padding) as:
IAED17شارة النقاط 1.7 101010Test seventeen 17D
As you can see, the order has changed - the numeric fields appear to have been included with the Arabic text.
This causes the API we're calling to break, as you can imagine - expected fields are not appearing in the right place.
The string is being built as follows:
StringBuffer paramBuffer = new StringBuffer(BUFFER_INITIAL_CAPACITY);
while (iterator.hasNext()){
String fieldName = iterator.next().toString();
// Get Object using field name from Vector.
FieldApi field = (FieldApi)fields.get(fieldName);
tempCtr = tempCtr + field.getLength();
if (field.getLength() == 0) {
break; // We have reached end of the fields
}
//Add each formatted field to param.
paramBuffer.append(field.getString());
}
}
Now, I suspect that I could get around this by constructing a byte array and using a setBytes method on my callableStatement. However, the set up of my
JDBC connection means that I can't use setBytes (translateBinary is set to true, giving a data type mismatch exception), and this set up is something I can't change.
I'm sure this is a problem with the fact that Arabic languages are right to left rather than left to right, and the String I create attempts to format it in this manner (and gets it wrong). Is there a way I can tell the String to leave things exactly as they're added, rather than messing around with them?
Any help would be appreciated! :-)
Cheers,
Dan