File tree Expand file tree Collapse file tree 3 files changed +18
-6
lines changed Expand file tree Collapse file tree 3 files changed +18
-6
lines changed Original file line number Diff line number Diff line change 6
6
7
7
### Fixed
8
8
- Fixed Bluetooth firmware updates sometimes failing on macOS. ([ support #1787 ] )
9
+ - Fixed multibyte unicode characters not printing correctly in terminal when
10
+ split across Bluetooth packets. ([ support #1743 ] )
9
11
10
- [[ support #1787 ]] : https://github.com/pybricks/support/issues/1787
12
+ [ support#1743 ] : https://github.com/pybricks/support/issues/1743
13
+ [ support#1787 ] : https://github.com/pybricks/support/issues/1787
11
14
12
15
## [ 2.3.0-beta.1] - 2023-11-24
13
16
Original file line number Diff line number Diff line change 1
1
// SPDX-License-Identifier: MIT
2
- // Copyright (c) 2020-2023 The Pybricks Authors
2
+ // Copyright (c) 2020-2024 The Pybricks Authors
3
3
4
4
import PushStream from 'zen-push' ;
5
5
import { AsyncSaga , delay } from '../../test' ;
@@ -86,6 +86,14 @@ describe('receiving stdout from hub', () => {
86
86
87
87
await expect ( saga . take ( ) ) . resolves . toEqual ( sendData ( ' ' ) ) ;
88
88
89
+ // ensure that unicode characters are handled correctly when split
90
+ // across buffers
91
+
92
+ saga . put ( didReceiveWriteStdout ( new Uint8Array ( [ 0xe4 ] ) . buffer ) ) ;
93
+ await expect ( saga . take ( ) ) . resolves . toEqual ( sendData ( '' ) ) ;
94
+ saga . put ( didReceiveWriteStdout ( new Uint8Array ( [ 0xb8 , 0xad ] ) . buffer ) ) ;
95
+ await expect ( saga . take ( ) ) . resolves . toEqual ( sendData ( '中' ) ) ;
96
+
89
97
await saga . end ( ) ;
90
98
} ) ;
91
99
} ) ;
Original file line number Diff line number Diff line change 1
1
// SPDX-License-Identifier: MIT
2
- // Copyright (c) 2020-2023 The Pybricks Authors
2
+ // Copyright (c) 2020-2024 The Pybricks Authors
3
3
4
4
import { AnyAction } from 'redux' ;
5
5
import {
@@ -39,7 +39,8 @@ import { receiveData, sendData } from './actions';
39
39
export type TerminalSagaContext = { terminal : TerminalContextValue } ;
40
40
41
41
const encoder = new TextEncoder ( ) ;
42
- const decoder = new TextDecoder ( ) ;
42
+ const uartDecoder = new TextDecoder ( ) ;
43
+ const stdoutDecoder = new TextDecoder ( ) ;
43
44
44
45
function * receiveUartData ( action : ReturnType < typeof didNotify > ) : Generator {
45
46
const { runtime : hubState , useLegacyStdio } = yield * select (
@@ -56,14 +57,14 @@ function* receiveUartData(action: ReturnType<typeof didNotify>): Generator {
56
57
return ;
57
58
}
58
59
59
- const value = decoder . decode ( action . value . buffer ) ;
60
+ const value = uartDecoder . decode ( action . value . buffer , { stream : true } ) ;
60
61
yield * put ( sendData ( value ) ) ;
61
62
}
62
63
63
64
function * handleReceiveWriteStdout (
64
65
action : ReturnType < typeof didReceiveWriteStdout > ,
65
66
) : Generator {
66
- const value = decoder . decode ( action . payload ) ;
67
+ const value = stdoutDecoder . decode ( action . payload , { stream : true } ) ;
67
68
yield * put ( sendData ( value ) ) ;
68
69
}
69
70
You can’t perform that action at this time.
0 commit comments