It is currently 13 Aug 2025, 19:41
   
Text Size

Oracle Text In cards.txt Files

Post MTG Forge Related Programming Questions Here

Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins

Re: Oracle Text In cards.txt Files

Postby Chris H. » 26 Jun 2011, 21:26

Braids wrote:here is why. examining the card in that rev, a hex editor shows the byte 0x9e is present where the "LATIN SMALL LETTER U WITH CIRCUMFLEX" belongs. this is neither UTF-8 nor ISO-Latin-1. it is Macintosh specific: http://kb.iu.edu/data/aeqb.html

edit 1: 0x9e isn't even defined by ISO-Latin-1. but in the Windows-1252 encoding, you get the accented Z. http://en.wikipedia.org/wiki/Windows-1252 (column E, row 9)
`
Wow.

UTF-8 and ISO-8859-1 and now Mac OS Roman plus Windows-1252.

It has been an interesting and educational day.

I reverted my card name change. :D
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: Oracle Text In cards.txt Files

Postby Snacko » 26 Jun 2011, 22:12

whole solution is to convert utf-8 to unicode as this is what Java uses for strings sample code that fixes all the issues with names showing wrong characters.
Code: Select all
try {
               t = new String(t.getBytes(), "UTF-8");
            } catch (UnsupportedEncodingException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
            }
Snacko
DEVELOPER
 
Posts: 826
Joined: 29 May 2008, 19:35
Has thanked: 4 times
Been thanked: 74 times

Re: Oracle Text In cards.txt Files

Postby Braids » 26 Jun 2011, 23:17

Snacko wrote:whole solution is to convert utf-8 to unicode as this is what Java uses for strings
yes, but the best place to do this is where the file is being loaded. having UTF-8 encoded Strings running around is unnecessarily confusing and error prone. the UTF-8 must be decoded as part of the process of creating the String in the first place. that is why we must make a decision about the character encoding of the file itself.

here is how to read a UTF-8 encoded file into Java:
Code: Select all
FileInputStream inStream;
InputStreamReader streamReader;
BufferedReader bufReader;
try {
    inStream = new FileInputStream(file);
    streamReader = new InputStreamReader(inStream, "UTF-8");
    bufReader = new BufferedReader(streamReader);

    String line = bufReader.getLine();
    // ...
}
// TODO catch Exceptions here, like UnsupportedEncodingException
finally {
    try { bufReader.close(); } catch (Exception ignored) { ; }
    try { streamReader.close(); } catch (Exception ignored) { ; }
    try { inStream.close(); } catch (Exception ignored) { ; }
}
also, we have to make sure that the values placed into those files have the correct encoding as well.

for the short term, i think ascii is still the best plan. we have bigger fish to fry.
"That is the dumbest thing I've ever seen." --Rob Cashwalker, regarding Innistrad double-sided cards. One of the first times he and I have ever agreed on something. ;)
User avatar
Braids
Programmer
 
Posts: 556
Joined: 22 Jun 2011, 00:39
Location: Unknown. Hobby: Driving myself and others to constructive madness.
Has thanked: 1 time
Been thanked: 1 time

changing the default charset for txt files

Postby Braids » 27 Jun 2011, 00:39

Braids wrote:. . . the best place to do this is where the file is being loaded.
in a fit of irony, i found myself editing the very file that loads card data from disk. this is in my current effort to modify CardFactory to load cards on demand instead of all at once. of course, there are parts of the code that want all the cards loaded all at once anyway. i'm not fixing those yet.
Code: Select all
public class ReadCard implements Runnable, NewConstants {
    public static final String DEFAULT_CHARSET_NAME = "US-ASCII";
    //...
}
it hasn't been committed yet. but change that constant and you change everything.

apologies in advance to Rob. i am trying to limit the number of files i change in this effort, but it is more than i originally anticipated. hmm, there are some files where i only added comments. i can commit those in the next couple of hours. it's a plan.
"That is the dumbest thing I've ever seen." --Rob Cashwalker, regarding Innistrad double-sided cards. One of the first times he and I have ever agreed on something. ;)
User avatar
Braids
Programmer
 
Posts: 556
Joined: 22 Jun 2011, 00:39
Location: Unknown. Hobby: Driving myself and others to constructive madness.
Has thanked: 1 time
Been thanked: 1 time

Re: Oracle Text In cards.txt Files

Postby friarsol » 27 Jun 2011, 02:24

Alright, so back to the original point of this thread. Should I be doing anything to the Oracle text of the cards with non-ASCII characters? I'll hold off committing the updated script, I just was gone most of the weekend and didn't get to read up on anything conclusive.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Oracle Text In cards.txt Files

Postby Braids » 27 Jun 2011, 02:32

friarsol wrote:Alright, so back to the original point of this thread. Should I be doing anything to the Oracle text of the cards with non-ASCII characters? I'll hold off committing the updated script, I just was gone most of the weekend and didn't get to read up on anything conclusive.
despite the change i made, i'm still voting ascii, so that gives ascii a narrow margin of one vote.

i guess i can unilaterally declare the voting over and recommend total conversion to ascii.
"That is the dumbest thing I've ever seen." --Rob Cashwalker, regarding Innistrad double-sided cards. One of the first times he and I have ever agreed on something. ;)
User avatar
Braids
Programmer
 
Posts: 556
Joined: 22 Jun 2011, 00:39
Location: Unknown. Hobby: Driving myself and others to constructive madness.
Has thanked: 1 time
Been thanked: 1 time

Re: Oracle Text In cards.txt Files

Postby friarsol » 27 Jun 2011, 02:36

Braids wrote:i guess i can unilaterally declare the voting over and recommend total conversion to ascii.
You can?
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Oracle Text In cards.txt Files

Postby Rob Cashwalker » 27 Jun 2011, 02:39

ascii... I was testing the sealed mode missing land issue, and kept getting exceptions because Dandan can't be found by CardFactory.

edit - look, the forum recognizes Dandan without the funny looking "a".
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

votes so far

Postby Braids » 27 Jun 2011, 03:06

  • ascii: Braids, friarsol, Rob Cashwalker
  • utf-8: Hellfish
  • abstain: Chris H., Jaedayr

ascii wins 3:1.
"That is the dumbest thing I've ever seen." --Rob Cashwalker, regarding Innistrad double-sided cards. One of the first times he and I have ever agreed on something. ;)
User avatar
Braids
Programmer
 
Posts: 556
Joined: 22 Jun 2011, 00:39
Location: Unknown. Hobby: Driving myself and others to constructive madness.
Has thanked: 1 time
Been thanked: 1 time

Re: Oracle Text In cards.txt Files

Postby Braids » 27 Jun 2011, 03:08

Rob Cashwalker wrote:look, the forum recognizes Dandan without the funny looking "a".
imp mode: yes, but its oracle text includes the circumflex over the a. :mrgreen:

i'm still voting ascii in the card text.
"That is the dumbest thing I've ever seen." --Rob Cashwalker, regarding Innistrad double-sided cards. One of the first times he and I have ever agreed on something. ;)
User avatar
Braids
Programmer
 
Posts: 556
Joined: 22 Jun 2011, 00:39
Location: Unknown. Hobby: Driving myself and others to constructive madness.
Has thanked: 1 time
Been thanked: 1 time

Re: Oracle Text In cards.txt Files

Postby Rob Cashwalker » 27 Jun 2011, 04:02

Braids - don't be afraid to include more than one response in a post... use the edit button if necessary... I know you're new and trying to bump up your post count....

Yes, I did notice that it uses the weird a in the text...

Why exactly did all this come up anyway? Just because the Oracle text friarsol is going to use may include weird characters that don't match our card names? The Oracle text part is just for human reference... I think our brains can skip to the punchline, and ignore weird symbols. As long as Card.getName is consistent with existing data, then Forge is functional. The printed text of the card can be anything, it doesn't have to match a deck file...
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Re: Oracle Text In cards.txt Files

Postby Braids » 27 Jun 2011, 04:15

Rob Cashwalker wrote:Braids - don't be afraid to include more than one response in a post... use the edit button if necessary... I know you're new and trying to bump up your post count....
actually, i wasn't considering my post count at all. does the subscription system notify its subscribers if i edit a post? i have been assuming it didn't.

Rob Cashwalker wrote:Why exactly did all this come up anyway? Just because the Oracle text friarsol is going to use may include weird characters that don't match our card names? The Oracle text part is just for human reference... I think our brains can skip to the punchline, and ignore weird symbols.
yes, but if those weird symbols are a math radical symbol following by a backwards Russian R, when it's supposed to be a LATIN SMALL LETTER A WITH MACRON, it not only looks really really bad, it is beyond the realm of sensible legibility. those are the kinds of behavior we were getting.

the oracle text has to undergo transformation for mana and tap symbols anyway; we may as well asciify it to make it legible. also, function is not everything.
"That is the dumbest thing I've ever seen." --Rob Cashwalker, regarding Innistrad double-sided cards. One of the first times he and I have ever agreed on something. ;)
User avatar
Braids
Programmer
 
Posts: 556
Joined: 22 Jun 2011, 00:39
Location: Unknown. Hobby: Driving myself and others to constructive madness.
Has thanked: 1 time
Been thanked: 1 time

Re: Oracle Text In cards.txt Files

Postby Hellfish » 27 Jun 2011, 11:25

It's like election night with all the vote tracking ;)
I'll edit this post when things are back to normal.
EDIT:Done as of r10097.
Last edited by Hellfish on 27 Jun 2011, 11:47, edited 1 time in total.
So now you're
Screaming for the blood of the cookie monster
Evil puppet demon of obesity
Time to change the tune of his fearful ballad
C is for "Lettuce," that's good enough for me
User avatar
Hellfish
Programmer
 
Posts: 1297
Joined: 07 Jun 2009, 10:41
Location: South of the Pumphouse
Has thanked: 110 times
Been thanked: 169 times

Re: Oracle Text In cards.txt Files

Postby Rob Cashwalker » 27 Jun 2011, 11:35

Braids, just a little gentle hazing... no harm. To be honest, I don't know much about the subscription mode....
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Re: Oracle Text In cards.txt Files

Postby ZzzzSleep » 27 Jun 2011, 11:45

Even though all I've done is script some cards, my vote (if I get one) is to use the ascii version of the text. Otherwise, somebody could have the situation of a cursed scroll in play and no idea how to type 'Ærathi Berserker'.
ZzzzSleep
 
Posts: 182
Joined: 29 Oct 2010, 02:19
Has thanked: 18 times
Been thanked: 18 times

PreviousNext

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 25 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 25 users online :: 0 registered, 0 hidden and 25 guests (based on users active over the past 10 minutes)
Most users ever online was 7303 on 15 Jul 2025, 20:46

Users browsing this forum: No registered users and 25 guests

Login Form