File tree Expand file tree Collapse file tree 2 files changed +11
-15
lines changed
src/main/java/com/yanglb/codegen Expand file tree Collapse file tree 2 files changed +11
-15
lines changed Original file line number Diff line number Diff line change 2424import com .yanglb .codegen .utils .Infos ;
2525import com .yanglb .codegen .utils .Resources ;
2626import com .yanglb .codegen .utils .StringUtil ;
27- import org .apache .commons .text .StringEscapeUtils ;
2827
2928public class MsgIOSTranslatorImpl extends BaseMsgTranslator {
3029 @ Override
@@ -73,11 +72,7 @@ protected void onTranslate() throws CodeGenException {
7372 private String escape (String value ) {
7473 if (value == null ) return null ;
7574
76- value = value .replaceAll ("\\ \\ " , "\\ \\ \\ \\ " );
77- value = value .replaceAll ("\" " , "\\ \\ \" " );
78-
79- value = value .replaceAll ("\r " , "" );
80- value = value .replaceAll ("\n " , "\\ \\ n" );
75+ value = StringUtil .escapeIOSString (value );
8176 return value ;
8277 }
8378}
Original file line number Diff line number Diff line change @@ -62,17 +62,18 @@ public static List<String> findFlags(String data) {
6262 }
6363
6464 /**
65- * 字符串转换unicode
66- * @param string
65+ * 处理IOS字符串
66+ * @param value
6767 * @return
6868 */
69- public static String string2Unicode (String string ) {
70- StringBuffer unicode = new StringBuffer ();
71- for (int i = 0 ; i < string .length (); i ++) {
72- char c = string .charAt (i );
73- unicode .append ("\\ u" + Integer .toHexString (c ));
74- }
69+ public static String escapeIOSString (String value ) {
70+ if (value == null ) return null ;
71+
72+ value = value .replaceAll ("\\ \\ " , "\\ \\ \\ \\ " );
73+ value = value .replaceAll ("\" " , "\\ \\ \" " );
7574
76- return unicode .toString ();
75+ value = value .replaceAll ("\r " , "" );
76+ value = value .replaceAll ("\n " , "\\ \\ n" );
77+ return value ;
7778 }
7879}
You can’t perform that action at this time.
0 commit comments