• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
  • entries
    46
  • comments
    91
  • views
    64100

Using UTF-8 in Games

Sign in to follow this  
Followers 0
Squared'D

2636 views

[font=arial]

Using UTF-8 in Games

[/font]

[font=arial]

After working on my GUI system, I really started to explore using UTF-8 more in my game. I'm currently living in Korea and that has made me see how important it is to give people games in their language. The kids I teach are just crazy about video games. The game Starcraft, for example, was at one time so popular in Korea, it spawned sponsored professional game players. Matches can be even seen on game-specific cable television networks. There is a large international desire for games and developers should build their games with this in mind.

[/font]

[font=arial]

I've started looking at UTF-8 these days and trying to explore it. I've written an article on it and I've even made a video presentation based on that article. And if you like want source code, on my other blog, I'm currently writing a series Writing a STL-Style UTF-8 String Class. It will be a five part series that I should finish by Friday. If it gets a nice reception, I'll post a summary article here on Gamedev. Even with all of this information, plus the countless articles on the Internet, how can someone actually use UTF-8 in a game?

[/font]

[font=arial]

UTF-8 is a Unicode encoding. One good thing about UTF-8 is it's a variable-sized 8 bit encoding. This means that games developed using 7 bit ASCII(the 8 bit "char" data type in C and C++) will not need to alter their file formats that store text. This is because 7-bit ASCII is a subset of UTF-8 and UTF-8 can work with null-terminated c-style strings. All of the standard "char"-based string functions will work including search, concatenation, and comparison.

[/font]
[font=arial]

To use UTF-8 with a GUI, the text can be stored in UTF-8 and then converted during rendering. This can be done by iterating through the string to get the correct code point. For GUIs that render text that doesn't need further processing, this will work well. Edit boxes will be a little trickier since they will require random insertions of characters anywhere in the text field. This can be done using a good UTF-8 string class, but it would be better to not use UTF-8 in this case and convert later. This makes sense as an edit control will probably have it's own buffer for text anyway that will later be synchronized with the application.

[/font]

[font=arial]

Another thing UTF-8 is good for is sending data. Even when a game already uses wchar_t(16 bits on Windows), UTF-8 may still be used when communicating with other programs over a network. Many network libraries and many servers require request to be sent in JSON or XML encoded in UTF-8 so even if the program stores it's text internally as wchar_t, conversion to UTF-8 may still be needed. UTF-8 is good for sending data because it is endian-independent. One example of this is the RakNet master server implementation by Jenkins Software. To use it, applications should send data in JSON over HTTP. User names, chat messages, and room details can all be encoded in UTF-8.

[/font]

[font=arial]

I'll continue to post about my progress and as I get more information I'll also post it here.

[/font]

5
Sign in to follow this  
Followers 0


11 Comments


Very interesting. I'm personally surprised you're going to work on edit support; finding out the insertion point (potentially) requires consistent support for Unicode layout. Just thinking at it makes my head hurt.

Personally I use UTF8 for serialization purposes only.

2

Share this comment


Link to comment

You're right. No one is going to make a living trying to edit a UTF-8 string. Just referencing a character by index is an O(n) function compared with O(1) with usually a fixed-size type. The most useful methods I think this class will have will be the string operations like copy, find, rfind, find_first_of, find_last_of, substr, and compare. I've already written the basic UTF-8 utility functions that I'll need to put together the string class. Some parts of the class may be a little overkill, but it's a fun little project.

0

Share this comment


Link to comment
I definitely wouldn'ttry to continously edit a UTF-8 string. I'm providing the capability in my utf8string class solely becauseI want it to be as much like std::string as possible. That's the goal of my little exercisie, but I'm also providing stand-a-lone functions that don't have the STL overhead.
0

Share this comment


Link to comment

Editing UTF is easier if you do it in UTF32, as all chars are fixed with, then for storage convert to utf8 and vice versa. It costs more but you aren't editing a string often in a game. And for mobile or console games this stuff is even less of a hassle because they supply edit boxes in the OS which you should just invoke and ask the string from that :)

0

Share this comment


Link to comment

Editing UTF is easier if you do it in UTF32, as all chars are fixed with, then for storage convert to utf8 and vice versa. It costs more but you aren't editing a string often in a game. And for mobile or console games this stuff is even less of a hassle because they supply edit boxes in the OS which you should just invoke and ask the string from that smile.png

 

I agree. This is what I do too.

 

BTW, here's the completed string class. It has all of the std::string methods minus some of the overloads. I'm still working on the class and hope to have it on Source Forge or something similar within a week or two. It was a fun little side project for me. I feel that I know STL much more intimately now.

 

http://squaredprogramming.blogspot.kr/2013/12/writing-stl-style-utf-8-string-class5.html

0

Share this comment


Link to comment

Try windows IME.


Windows IME is used for entering text whereas UTF-8 is an encoding for transmitting and storing text. The two can be used together.

0

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now