mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-13 15:34:38 +01:00
replace outdated code
This commit is contained in:
@@ -58,31 +58,6 @@ func (sc *StringConverter) MustEncode(data string) []byte {
|
|||||||
return encoded
|
return encoded
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
func MustConvertShiftJISToUTF8(text string) string {
|
|
||||||
result, err := ConvertShiftJISToUTF8(text)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
func MustConvertUTF8ToShiftJIS(text string) string {
|
|
||||||
result, err := ConvertUTF8ToShiftJIS(text)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
func ConvertShiftJISToUTF8(text string) (string, error) {
|
|
||||||
r := bytes.NewBuffer([]byte(text))
|
|
||||||
decoded, err := ioutil.ReadAll(transform.NewReader(r, japanese.ShiftJIS.NewDecoder()))
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
return string(decoded), nil
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
func UTF8ToSJIS(x string) []byte {
|
func UTF8ToSJIS(x string) []byte {
|
||||||
e := japanese.ShiftJIS.NewEncoder()
|
e := japanese.ShiftJIS.NewEncoder()
|
||||||
xt, _, err := transform.String(e, x)
|
xt, _, err := transform.String(e, x)
|
||||||
@@ -169,22 +144,3 @@ func CSVElems(csv string) []int {
|
|||||||
}
|
}
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConvertUTF8ToShiftJIS converts a UTF8 string to a Shift-JIS []byte.
|
|
||||||
func ConvertUTF8ToShiftJIS(text string) ([]byte, error) {
|
|
||||||
r := bytes.NewBuffer([]byte(text))
|
|
||||||
encoded, err := ioutil.ReadAll(transform.NewReader(r, japanese.ShiftJIS.NewEncoder()))
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return encoded, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func ConvertUTF8ToSJIS(text string) (string, error) {
|
|
||||||
r, _, err := transform.String(japanese.ShiftJIS.NewEncoder(), text)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
return r, nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -248,11 +248,7 @@ func handleMsgMhfGetGuildScoutList(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
bf.WriteUint32(uint32(TimeAdjusted().Unix()))
|
bf.WriteUint32(uint32(TimeAdjusted().Unix()))
|
||||||
bf.WriteUint16(0x00) // HR?
|
bf.WriteUint16(0x00) // HR?
|
||||||
bf.WriteUint16(0x00) // GR?
|
bf.WriteUint16(0x00) // GR?
|
||||||
|
bf.WriteBytes(stringsupport.PaddedString(charName, 32, true))
|
||||||
charNameBytes, _ := stringsupport.ConvertUTF8ToShiftJIS(charName)
|
|
||||||
|
|
||||||
bf.WriteBytes(charNameBytes)
|
|
||||||
bf.WriteBytes(make([]byte, 32-len(charNameBytes))) // Fixed length string
|
|
||||||
count++
|
count++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user