File tree Expand file tree Collapse file tree 1 file changed +23
-4
lines changed
delphi-frontend/src/main/java/au/com/integradev/delphi/antlr/ast/node Expand file tree Collapse file tree 1 file changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -135,10 +135,7 @@ private String createSingleLineValue() {
135135 break ;
136136
137137 case CHARACTER_ESCAPE_CODE :
138- String escapedChar = child .getImage ();
139- boolean isHex = escapedChar .startsWith ("#$" );
140- escapedChar = escapedChar .substring (isHex ? 2 : 1 );
141- imageBuilder .append ((char ) Integer .parseInt (escapedChar , isHex ? 16 : 10 ));
138+ imageBuilder .append (characterEscapeToChar (child .getImage ()));
142139 break ;
143140
144141 case ESCAPED_CHARACTER :
@@ -153,6 +150,28 @@ private String createSingleLineValue() {
153150 return imageBuilder .toString ();
154151 }
155152
153+ private static char characterEscapeToChar (String image ) {
154+ image = image .substring (1 );
155+ int radix = 10 ;
156+
157+ switch (image .charAt (0 )) {
158+ case '$' :
159+ radix = 16 ;
160+ image = image .substring (1 );
161+ break ;
162+ case '%' :
163+ radix = 2 ;
164+ image = image .substring (1 );
165+ break ;
166+ default :
167+ // do nothing
168+ }
169+
170+ image = StringUtils .remove (image , '_' );
171+
172+ return (char ) Integer .parseInt (image , radix );
173+ }
174+
156175 @ Override
157176 public boolean isMultiline () {
158177 return getChild (0 ).getTokenType () == DelphiTokenType .MULTILINE_STRING ;
You can’t perform that action at this time.
0 commit comments