Skip to content

Commit

Permalink
DecodeIndex: Fix invalid value of PADDING_MAX
Browse files Browse the repository at this point in the history
  • Loading branch information
1552980358 committed Jan 3, 2024
1 parent 1ea0912 commit 3fedb2a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
10 changes: 5 additions & 5 deletions src/main/kotlin/org/ks/chan/c2pinyin/decode/DecodeIndex.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,19 @@ internal val Char.tableIndex: Int
* [Int.pinyinIndex]
* @access Private
* @param encoding [Encoding]
* @param charOffset [Int]
* @param offset [Int]
* @param indexRaw [Int]
* @return [Int]
*
* Convert [Char.code] into index of pinyin table
**/
private fun Int.pinyinIndex(
encoding: Encoding = this.encoding,
charOffset: Int = this - encoding.offset,
indexRaw: Int = encoding.calculateIndex(charOffset)
offset: Int = this - encoding.offset,
indexRaw: Int = encoding.calculateIndex(offset)
): Int {
return when {
encoding.checkPaddingCorrection(charOffset) -> {
encoding.checkPaddingCorrection(offset) -> {
indexRaw or PADDING_MASK
}
else -> indexRaw
Expand All @@ -77,7 +77,7 @@ private const val INDEX_MAX = 0xFF
*
* Maximum padding of pinyin table
**/
private const val PADDING_MAX = 0xF
private const val PADDING_MAX = 8

/**
* [Encoding.calculateIndex]
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/org/ks/chan/c2pinyin/decode/Encoding.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import kotlin.io.encoding.ExperimentalEncodingApi

private const val OFFSET_PADDING_START = 0
private const val OFFSET_BASE = 19968
private const val OFFSET_ENCODING_PART_DIFFERENCE = 7000
internal const val OFFSET_ENCODING_PART_DIFFERENCE = 7000

/**
* [Encoding]
Expand Down
Loading

0 comments on commit 3fedb2a

Please sign in to comment.