Jump to content


Photo

Codepage Converter


  • Please log in to reply
5 replies to this topic

#1 Black Doomer

Black Doomer

    GMC Member

  • GMC Member
  • 105 posts
  • Version:GM8.1

Posted 26 January 2013 - 04:13 PM

Do...
...your non-English Max WinAPI 2 interfaces display a bunch of random symbols instead of proper strings?
...39DLL or other networking libs send non-English strings in sizes which are at least twice as big as those strings' lenghts?
in Game Maker 8.1?

Or do you have a similar problem and don't know what to do?

Yes, these are common problems when using Game Maker 8.1 and old extensions created for earlier versions of GM.
It's known that GM 8.1 began to use two-bytes Unicode (UTF-8) instead of the default one-byte codepages.
 

But now it's not a problem!
That's where the
-= CODEPAGE CONVERTER =-
comes in.

What does this thing actually do?
Codepage Converter is an extension for Game Maker to provide string conversion between different codepages.
It's recommended to use when you send strings to the extension which expects ANSI or when you get ANSI string results from the extension which GM 8.1 doesn't understand.
This ensures compatibility between GM 8.1 and old extensions.

How do I use this extension?
Codepage Converter is simple as an orange. There are two ways how to use it:
 

//ext_get_string() and ext_give_string() are imagined functions to show the principle of work
//first returns one-byted string, second waits for one-byted string

var result_str; //variable to get one-byted string result from the imagined extension ;)

//FIRST WAY
set_cpconv(1251); //sets ANSI-1251 codepage for all standard converting processes
result_str = to_utf8(ext_get_string()); //getting one-byted string result and converting it from ANSI-1251 to the UTF-8 codepage
ext_give_string(from_utf8(result_str)); //converting UTF-8 string to the ANSI-1251 codepage and sending it to the function

//SECOND WAY
result_str = to_utf8_alt(ext_get_string(), 1251); //getting one-byted string result and converting it from ANSI-1251 to the UTF-8 codepage
ext_give_string(from_utf8_alt(result_str, 1251)); //converting UTF-8 string to the ANSI-1251 codepage and sending it to the function

Full descriptions of all functions and predefined constants you can read in the ReadMe.txt which is in the archive with the extension.

How does this extension work?
Codepage Converter uses WinAPI functions WideCharToMultiByte() and MultiByteToWideChar() to perform the string conversion. That is, this extension will only work on the Windows version of Game Maker 8.1. If someone wants to rewrite this extension to increase the perfomance, reduce extension file size, create a cross-platform version or for something like that, I'll be all for it.

Thanks to
Stanislav Budinov aka trew for the help with understanding working principles of WinAPI functions.
PrimuS for the help with writing this post on English. :D

Download:
http://www.mediafire...1dcg7l10iwk6lq6 (~5 Kb; .7z)

Previous version was downloaded... 24 times.)

If you have any questions about the library, any requests or any bug reports, do post them here. I'll be glad to answer you.
I hope you will find this stuff useful. smile.gif


Edited by Black Doomer, 11 May 2013 - 03:51 AM.

  • 0

And sorry for my bad English.

My projects: Doom 2D Multiplayer

My extensions: Codepage Converter | XP Messages | Bit Wizard | Time Library

Other: Download Manager 2 GEX


#2 Black Doomer

Black Doomer

    GMC Member

  • GMC Member
  • 105 posts
  • Version:GM8.1

Posted 28 January 2013 - 05:34 AM

As many as 5 downloads (lol), 65 views... and 0 comments.
I would like to see more of these here. :)
  • 1

And sorry for my bad English.

My projects: Doom 2D Multiplayer

My extensions: Codepage Converter | XP Messages | Bit Wizard | Time Library

Other: Download Manager 2 GEX


#3 Black Doomer

Black Doomer

    GMC Member

  • GMC Member
  • 105 posts
  • Version:GM8.1

Posted 31 March 2013 - 12:33 PM

Uploaded a new version - some optimizations in the code and smaller size.


  • 0

And sorry for my bad English.

My projects: Doom 2D Multiplayer

My extensions: Codepage Converter | XP Messages | Bit Wizard | Time Library

Other: Download Manager 2 GEX


#4 Black Doomer

Black Doomer

    GMC Member

  • GMC Member
  • 105 posts
  • Version:GM8.1

Posted 11 May 2013 - 03:53 AM

New version of the extension released - fixed one critical bug with DLL releasing.

Link in the first post was updated.

 

It's so sad that there's no any feedback.(


Edited by Black Doomer, 11 May 2013 - 03:53 AM.

  • 1

And sorry for my bad English.

My projects: Doom 2D Multiplayer

My extensions: Codepage Converter | XP Messages | Bit Wizard | Time Library

Other: Download Manager 2 GEX


#5 Black Doomer

Black Doomer

    GMC Member

  • GMC Member
  • 105 posts
  • Version:GM8.1

Posted 12 May 2013 - 04:08 AM

Reuploaded this again - fixed one memory leak, improved helplines.


  • 1

And sorry for my bad English.

My projects: Doom 2D Multiplayer

My extensions: Codepage Converter | XP Messages | Bit Wizard | Time Library

Other: Download Manager 2 GEX


#6 Black Doomer

Black Doomer

    GMC Member

  • GMC Member
  • 105 posts
  • Version:GM8.1

Posted 05 October 2013 - 04:30 AM

Uploaded a new version. Extension size was slightly reduced.


  • 0

And sorry for my bad English.

My projects: Doom 2D Multiplayer

My extensions: Codepage Converter | XP Messages | Bit Wizard | Time Library

Other: Download Manager 2 GEX