Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified AXMLEditor.jar
Binary file not shown.
36 changes: 23 additions & 13 deletions src/cn/wjdiankong/chunk/StringChunk.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package cn.wjdiankong.chunk;

import java.nio.charset.StandardCharsets;
import java.util.ArrayList;

import cn.wjdiankong.main.ParserChunkUtils;
import cn.wjdiankong.main.Utils;

public class StringChunk {
Expand Down Expand Up @@ -35,12 +37,11 @@ public byte[] getByte(ArrayList<String> strList){
src = Utils.addByte(src, stylePoolOffset);

byte[] strOffsets = new byte[0];
ArrayList<String> convertList = convertStrList(strList);


int len = 0;
for(int i=0;i<convertList.size();i++){
for(int i=0;i<strList.size();i++){
strOffsets = Utils.addByte(strOffsets, Utils.int2Byte(len));
len += (convertList.get(i).length()+4);//�����4�����ַ���ͷ�����ַ�������2���ֽڣ����ַ�����β��2���ֽ�
len += (strList.get(i).length() * 2 + 4);//�����4�����ַ���ͷ�����ַ�������2���ֽڣ����ַ�����β��2���ֽ�
}

src = Utils.addByte(src, strOffsets);//д��string offsetsֵ
Expand Down Expand Up @@ -140,20 +141,28 @@ public static StringChunk createChunk(byte[] byteSrc, int stringChunkOffset){
while(chunk.stringContentList.size() < chunkStringCount){
//һ���ַ���Ӧ�����ֽڣ�����Ҫ����2
int stringSize = Utils.byte2Short(Utils.copyByte(chunkStringContentByte, endStringIndex, 2))*2;
byte[] temp = Utils.copyByte(chunkStringContentByte, endStringIndex+2, stringSize+2);
String str = new String(temp);
String str;
if (stringSize == 0) {
// ���ַ���
str = "";
}else{
byte[] temp = Utils.copyByte(chunkStringContentByte, endStringIndex + 2, stringSize);
str = new String(temp, StandardCharsets.UTF_16LE);
}
chunk.stringContentList.add(Utils.filterStringNull(str));
endStringIndex += (2+stringSize+2);
}
// �����������λ00
endStringIndex += 2;

int len = 0;
for(String str : chunk.stringContentList){
len += 2;
len += str.length()*2;
len += 2;
}
chunk.strPool = Utils.copyByte(byteSrc, stringContentStart, len);
int stylePool = stringContentStart + len;
chunk.strPool = Utils.copyByte(byteSrc, stringContentStart, endStringIndex);
int stylePool = stringContentStart + endStringIndex;

chunk.stylePool = Utils.copyByte(byteSrc, stylePool, chunkSize-(stylePool));

Expand All @@ -162,16 +171,17 @@ public static StringChunk createChunk(byte[] byteSrc, int stringChunkOffset){

private byte[] getStrListByte(ArrayList<String> strList){
byte[] src = new byte[0];
ArrayList<String> stringContentList = convertStrList(strList);
for(int i=0;i<stringContentList.size();i++){
for(int i=0;i<strList.size();i++){
String str = strList.get(i);
byte[] tempAry = new byte[0];
short len = (short)(stringContentList.get(i).length()/2);
short len = (short) str.length();
byte[] lenAry = Utils.shortToByte(len);
tempAry = Utils.addByte(tempAry, lenAry);
tempAry = Utils.addByte(tempAry, stringContentList.get(i).getBytes());
tempAry = Utils.addByte(tempAry, new byte[]{0,0});
tempAry = Utils.addByte(tempAry, str.getBytes(StandardCharsets.UTF_16LE));
tempAry = Utils.addByte(tempAry, new byte[]{0, 0});
src = Utils.addByte(src, tempAry);
}
src = Utils.addByte(src, new byte[]{0, 0});
return src;
}

Expand Down