Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
platform
/
platform-charging-server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit e09a4395
authored
Nov 21, 2023
by
谢海旭
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
实现 Ocpp16Helper.strToAscii 方法
1 parent
b3abfe49
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
17 deletions
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/Ocpp16Helper.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/Ocpp16Helper.java
View file @
e09a439
...
@@ -175,27 +175,26 @@ public class Ocpp16Helper {
...
@@ -175,27 +175,26 @@ public class Ocpp16Helper {
return
bcdBytes
;
return
bcdBytes
;
}
}
public
static
byte
[]
strToAscii
(
String
input
,
byte
[]
bcdBytes
)
{
/**
int
len
=
input
.
length
();
* 字符串 转ascii字节数组
int
mod
=
len
%
2
;
* 不足指定长度,默认后面补零
*
if
(
mod
!=
0
)
{
* @param str 字符串
input
=
"0"
+
input
;
// 补齐偶数位
* @param asciiBytes ascii字节数组(长度限定)
len
=
input
.
length
();
* @return
*/
public
static
byte
[]
strToAscii
(
String
str
,
byte
[]
asciiBytes
)
{
if
(
str
.
length
()
>
asciiBytes
.
length
)
{
throw
new
IllegalArgumentException
(
"The str length is greater than the asciiBytes length"
);
}
}
for
(
int
i
=
0
;
i
<
len
;
i
+=
2
)
{
char
[]
charArray
=
str
.
toCharArray
();
char
highChar
=
input
.
charAt
(
i
);
int
length
=
charArray
.
length
;
char
lowChar
=
input
.
charAt
(
i
+
1
);
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
asciiBytes
[
i
]
=
(
byte
)
charArray
[
i
];
int
high
=
Character
.
digit
(
highChar
,
10
);
int
low
=
Character
.
digit
(
lowChar
,
10
);
byte
bcdByte
=
(
byte
)
((
high
<<
4
)
|
low
);
bcdBytes
[
i
/
2
]
=
bcdByte
;
}
}
return
bcd
Bytes
;
return
ascii
Bytes
;
}
}
public
static
byte
[]
binToBytes
(
String
binaryString
)
{
public
static
byte
[]
binToBytes
(
String
binaryString
)
{
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment