Skip to content

Commit 1c9e0ae

Browse files
committed
update
1 parent cf1460b commit 1c9e0ae

4 files changed

Lines changed: 27 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44

55
***
66

7-
### [v3.5.3]
7+
### [v3.5.4]
88

99
**Fixed**:
1010
- Duplicated include path items: `.eide/deps` in project.
1111
- Can not parse old version `JLinkDevices.xml`.
12+
- Enum serialport failed when use `65001` code-page in windows os.
1213

1314
**Optimized**:
1415
- Optimize cpptools config provider for `gcc` family compilers.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"homepage": "https://github.com/github0null/eide/blob/master/README.md",
3333
"license": "MIT",
3434
"description": "A mcu development environment for 8051/AVR/STM8/Cortex-M/RISC-V",
35-
"version": "3.5.3",
35+
"version": "3.5.4",
3636
"preview": false,
3737
"engines": {
3838
"vscode": "^1.63.0"
@@ -60,7 +60,7 @@
6060
"readme": "https://github.com/github0null/eide/blob/master/README.md",
6161
"bugs": {
6262
"url": "https://github.com/github0null/eide/issues",
63-
"email": "2584456014@qq.com"
63+
"email": "me@github0null.io"
6464
},
6565
"repository": {
6666
"url": "https://github.com/github0null/eide.git",

src/CodeConverter.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,26 @@ export enum CodeType {
3838

3939
export class CodeConverter {
4040

41+
static trimUtf8BomHeader(str: string | Buffer): string {
42+
43+
if (str instanceof Buffer) {
44+
if (str[0] == 0xef &&
45+
str[1] == 0xbb &&
46+
str[2] == 0xbf) {
47+
str = str.subarray(3);
48+
}
49+
return str.toString();
50+
}
51+
52+
if (str.charCodeAt(0) == 0xef &&
53+
str.charCodeAt(1) == 0xbb &&
54+
str.charCodeAt(2) == 0xbf) {
55+
return str.substr(3);
56+
}
57+
58+
return str;
59+
}
60+
4161
private getCodeType(bomHead: Buffer): CodeType {
4262

4363
let codeType: CodeType;

src/ResManager.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import { SettingManager } from "./SettingManager";
4141
import * as utility from './utility'
4242
import { CmdLineHandler } from "./CmdLineHandler";
4343
import * as yaml from 'yaml';
44+
import { CodeConverter } from "./CodeConverter";
4445

4546
let resManager: ResManager | undefined;
4647

@@ -165,8 +166,8 @@ export class ResManager extends events.EventEmitter {
165166
enumSerialPort(): string[] {
166167
try {
167168
const cmd = `${this.getMonoName()} "${this.getSerialPortExe().path}"`;
168-
const data = ChildProcess.execSync(cmd, { env: process.env }).toString();
169-
const portList: string[] = JSON.parse(data);
169+
const data = ChildProcess.execSync(cmd, { env: process.env });
170+
const portList: string[] = JSON.parse(CodeConverter.trimUtf8BomHeader(data));
170171
if (!Array.isArray(portList)) { throw Error("get current port list error !"); }
171172
return portList;
172173
} catch (error) {

0 commit comments

Comments
 (0)