Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
White Collar
BAPIDE
Commits
d3824844
Commit
d3824844
authored
Jun 19, 2025
by
王业明
Browse files
Fix:组件注册,先读原文件第一行,然后根据编码再读一次具体内容
parent
f37d9af2
Changes
1
Show whitespace changes
Inline
Side-by-side
cn.com.bankit.ide.bap.python.parser/src/cn/com/bankit/ide/bap/python/parser/PythonComponentParser.java
View file @
d3824844
...
@@ -420,6 +420,7 @@ public class PythonComponentParser implements PythonComponentConstants
...
@@ -420,6 +420,7 @@ public class PythonComponentParser implements PythonComponentConstants
{
{
this
.
file
=
file
;
this
.
file
=
file
;
BufferedReader
br
=
null
;
BufferedReader
br
=
null
;
charsetName
=
getCharsetName
(
file
,
charsetName
);
try
try
{
{
br
=
new
BufferedReader
(
new
InputStreamReader
(
new
FileInputStream
(
file
),
charsetName
));
br
=
new
BufferedReader
(
new
InputStreamReader
(
new
FileInputStream
(
file
),
charsetName
));
...
@@ -503,4 +504,47 @@ public class PythonComponentParser implements PythonComponentConstants
...
@@ -503,4 +504,47 @@ public class PythonComponentParser implements PythonComponentConstants
return
words
;
return
words
;
}
}
public
String
getCharsetName
(
File
file
,
String
charsetName
)
throws
PythonParseExcption
{
BufferedReader
br
=
null
;
try
{
br
=
new
BufferedReader
(
new
InputStreamReader
(
new
FileInputStream
(
file
),
charsetName
));
String
line
=
br
.
readLine
();
int
index
=
-
1
;
if
(
line
!=
null
)
{
if
((
index
=
line
.
indexOf
(
"# -*- coding:"
))
>
-
1
)
{
int
lastIdx
=
line
.
lastIndexOf
(
"-*-"
);
if
(
lastIdx
>
-
1
)
{
charsetName
=
line
.
substring
(
index
+
13
,
lastIdx
).
trim
();
}
else
{
charsetName
=
line
.
substring
(
index
+
13
).
trim
();
}
}
}
return
charsetName
;
}
catch
(
IOException
e
)
{
throw
new
PythonParseExcption
(
e
);
}
finally
{
if
(
br
!=
null
)
{
try
{
br
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment