mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-13 07:25:03 +01:00
prevent panic on invalid string transform
This commit is contained in:
@@ -11,7 +11,8 @@ func Uint8(bf *byteframe.ByteFrame, x string, t bool) {
|
|||||||
e := japanese.ShiftJIS.NewEncoder()
|
e := japanese.ShiftJIS.NewEncoder()
|
||||||
xt, _, err := transform.String(e, x)
|
xt, _, err := transform.String(e, x)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
bf.WriteUint8(0)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
x = xt
|
x = xt
|
||||||
}
|
}
|
||||||
@@ -24,7 +25,8 @@ func Uint16(bf *byteframe.ByteFrame, x string, t bool) {
|
|||||||
e := japanese.ShiftJIS.NewEncoder()
|
e := japanese.ShiftJIS.NewEncoder()
|
||||||
xt, _, err := transform.String(e, x)
|
xt, _, err := transform.String(e, x)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
bf.WriteUint16(0)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
x = xt
|
x = xt
|
||||||
}
|
}
|
||||||
@@ -37,7 +39,8 @@ func Uint32(bf *byteframe.ByteFrame, x string, t bool) {
|
|||||||
e := japanese.ShiftJIS.NewEncoder()
|
e := japanese.ShiftJIS.NewEncoder()
|
||||||
xt, _, err := transform.String(e, x)
|
xt, _, err := transform.String(e, x)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
bf.WriteUint32(0)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
x = xt
|
x = xt
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user