Team Spartan Cookies & Milk Forums
  • Issue Tracker
  • Donations
  • Search
  • Member List
  • Help

Register

Team Spartan Cookies & Milk Forums Garry's Mod Starfall v
« Previous 1 … 6 7 8 9 10 … 18 Next »
UTF-8 support
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Linear Mode
UTF-8 support
10-12-2017, 03:35 PM, (This post was last modified: 10-12-2017, 04:54 PM by Yuri6037. Edited 2 times in total.)
#1
Yuri6037 Offline
TSCM Member
***
Posts: 216
Threads: 45
Joined: Feb 2015
UTF-8 support
Hi,

I was trying to recreate a private chat system that only works with my Starfall Processor. To create the chat window I used VGUI.
More precisely a DPanel inside of which is a DTextEntry. The DTextEntry works fine as long as no non ascii characters are inputed.

However when some non ascii characters are printed (like the big TSCM letters) using TAB key based autocopletion (so using SetText + SetCaretPos), the game ends up freezing then crashes. I found a possible explanation to why it's disfunctional : when the autocompletion generated word is added the SetCaretPos is set to the end using string.len. It is possible that SetCaretPos expects a position in number of characters not in number of bytes. However string.len unfortuntaly does not support UTF-8 characters but instead returns the size in bytes of the string. Which then creates some unwanted spaces when used in SetCaretPos which then seam to crash the game later.

A possible fix would be either allowing us to access directly the keyboard key-type events and character type events and allow usage of utf8 library of GMod, that way we could recode DTextEntry. Another option would be to patch the SetCaretPos in lua and throwing errors in case of attempting to SetCaretPos outside the amount of characters and allowing us to access utf8 library so we can know the real length of a string, and not it's size in bytes.

I know it is possible to recode UTF-8 encoding in lua but it would be long and GMod already offers a library for that.

I'm however not sure about why exactly the game produces access violation, neither if using real length of string will fix the problem. However all I could notice is that SetCaretPos seam to cause the game to create access violation (and also causes weird space/unwanted character bugs in the DTextEntry) when used with string size in bytes.

EDIT : Apparently there are no longer crashes when using a quick basic implementation of UTF-8 encoding. I will keep testing in case the crash comes back...

Thanks,
Yuri6037
Find
Reply
« Next Oldest | Next Newest »


Messages In This Thread
UTF-8 support - by Yuri6037 - 10-12-2017, 03:35 PM
RE: UTF-8 support - by Person8880 - 10-12-2017, 06:02 PM
RE: UTF-8 support - by Yuri6037 - 10-12-2017, 09:22 PM

  • View a Printable Version
Forum Jump:


Users browsing this thread: 1 Guest(s)
Contact UsTeam Spartan Cookies & MilkReturn to TopLite (Archive) ModeMark all forums readRSS Syndication

Powered By MyBB, © 2002-2026 MyBB Group.