private String reEncodeWriteAccessIfNecessary( String writeAccess ) { if ( writeAccess == null || writeAccess.length() == 0 ) { return writeAccess; } byte[] data = new byte[112]; try { // jxl reads writeAccess with "UnicodeLittle" encoding, but will try to write later with "file.encoding" // this throws an ArrayIndexOutOfBoundsException in *nix systems StringHelper.getBytes( writeAccess, data, 0 ); } catch ( ArrayIndexOutOfBoundsException e ) { try { // properly re-encoding string from UnicodeLittle, removing BOM characters return new String( writeAccess.getBytes( "UnicodeLittle" ), System.getProperty( "file.encoding" ) ).substring( 2 ); } catch ( UnsupportedEncodingException e1 ) { logError( Const.getStackTracker( e ) ); } } return writeAccess; } }
/** * Gets the ASCII bytes from the specified string and places them in the * array at the specified position * * @param pos the position at which to place the converted data * @param s the string to convert * @param d the byte array which will contain the converted string data */ public static void getBytes(String s, byte[] d, int pos) { byte[] b = getBytes(s); System.arraycopy(b, 0, d, pos, b.length); }
/** * Gets the ASCII bytes from the specified string and places them in the * array at the specified position * * @param pos the position at which to place the converted data * @param s the string to convert * @param d the byte array which will contain the converted string data */ public static void getBytes(String s, byte[] d, int pos) { byte[] b = getBytes(s); System.arraycopy(b, 0, d, pos, b.length); }
/** * Constructor */ public WriteAccessRecord(String userName) { super(Type.WRITEACCESS); data = new byte[112]; String astring = userName != null ? userName : authorString + " v" + Workbook.getVersion(); StringHelper.getBytes(astring, data, 0); // Pad out the record with space characters for (int i = astring.length() ; i < data.length ;i++) { data[i] = 0x20; } }
/** * Constructor */ public WriteAccessRecord(String userName) { super(Type.WRITEACCESS); data = new byte[112]; String astring = userName != null ? userName : authorString + " v" + Workbook.getVersion(); StringHelper.getBytes(astring, data, 0); // Pad out the record with space characters for (int i = astring.length() ; i < data.length ;i++) { data[i] = 0x20; } }
private static byte[] getURL(String s, WorkbookSettings ws) { ByteArray byteArray = new ByteArray(); byteArray.add(unencodedUrl); byteArray.add((byte) s.length()); byteArray.add(StringHelper.getBytes(s, ws)); return byteArray.getBytes(); } }
private static byte[] getURL(String s, WorkbookSettings ws) { ByteArray byteArray = new ByteArray(); byteArray.add(unencodedUrl); byteArray.add((byte) s.length()); byteArray.add(StringHelper.getBytes(s, ws)); return byteArray.getBytes(); } }
byteArray.add(StringHelper.getBytes(nextFileNameComponent, ws));
byteArray.add(StringHelper.getBytes(nextFileNameComponent, ws));
StringHelper.getBytes(shortFilePath, d, curPos+4);
StringHelper.getBytes(shortFilePath, d, curPos+4);
StringHelper.getBytes(name, data, 15);
StringHelper.getBytes(name, data, 15);