Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7178925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:01:27+00:00 2026-05-28T17:01:27+00:00

I’m currently working on a program that converts japanese characters to english characters and

  • 0

I’m currently working on a program that converts japanese characters to english characters and the other way around.
It’s not working much though, For the last few days I’ve been trying everything to try and get it to work, it’s probably some small dumb problem but I just can’t find it. I’m pretty new to all this so any help is appreciated.

Now the problem is that it only wants to convert Romaji characters, however if change some code, more specifically if I change the following from “if” to else if, then it converts hiragana and katakana but NOT romaji..

        string fromtype = "";

        // Determines what type the character is currently
        // && fromtype == "" added to avoid weird unexplainable errors...
        if (CharacterTable.Select("Romaji = '" + character + "'") != null && fromtype == "")
        {
            fromtype = "Romaji";
        }
        else if (CharacterTable.Select("Hiragana = '" + character + "'") != null && fromtype == "")
        {
            fromtype = "Hiragana";
        }
        else if (CharacterTable.Select("Katakana = '" + character + "'") != null && fromtype == "")
        {
            fromtype = "Katakana";
        }

I’ve even tried removing this function that tries to automatically find what type the character is and do it with radiobuttons so that the user has to select it, but somehow it seems to do pretty much the same thing… So I’m totally confused at this point, any help is very much welcome.

Here is the full code:

public string CheckCharacter(string character, int RequestedCharType)
        {
            // RequestedCharType
            // 1 = Romaji
            // 2 = Hiragana
            // 3 = Katakana

            //-- Instantiate the data set and table
            DataSet CharacterDatabase = new DataSet();
            DataTable CharacterTable = CharacterDatabase.Tables.Add();

            //-- Add columns to the data table
            CharacterTable.Columns.Add("Romaji", typeof(string));
            CharacterTable.Columns.Add("Hiragana", typeof(string));
            CharacterTable.Columns.Add("Katakana", typeof(string));


            //-- Add rows to the data table
            CharacterTable.Rows.Add("a", "あ", "ア");
            CharacterTable.Rows.Add("i", "い", "イ");


            // Sets fromtype to the type the character(s) currently is/are
            string fromtype = "";

            // Determines what type the character is currently
            // && fromtype == "" added to avoid weird unexplainable errors...
            if (CharacterTable.Select("Romaji = '" + character + "'") != null && fromtype == "")
            {
                fromtype = "Romaji";
            }
            else if (CharacterTable.Select("Hiragana = '" + character + "'") != null && fromtype == "")
            {
                fromtype = "Hiragana";
            }
            else if (CharacterTable.Select("Katakana = '" + character + "'") != null && fromtype == "")
            {
                fromtype = "Katakana";
            }



           // generates a new variable to store the return in
           DataRow[] filteredRows = CharacterTable.Select(fromtype + " = '" + character + "'");

            // Return the converted character in the requested type
            foreach (DataRow row in filteredRows)
            {
                if (RequestedCharType == 1)
                {
                    return row["Romaji"].ToString();
                }
                if (RequestedCharType == 2)
                {
                    return row["Hiragana"].ToString();
                }
                if (RequestedCharType == 3)
                {
                    return row["Katakana"].ToString();
                }
            }


            // if it couldn't find the character, return the original character
            return character;
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T17:01:29+00:00Added an answer on May 28, 2026 at 5:01 pm

    Your problem is in your misunderstanding of how Select works. Select does not return null when there are no matches so your first if is always true. Instead you need to check whether there were any results which you can do with Enumerable.Any() (add using System.Linq):

    if (CharacterTable.Select("Romaji = '" + character + "'").Any())
    {
        fromtype = "Romaji";
    }
    else ...
    

    Alternatively you can check the array length:

    if (CharacterTable.Select("Romaji = '" + character + "'").Length > 0)
    {
        fromtype = "Romaji";
    }
    else ...
    
    • I’m not sure what the fromType == "" bit is all about this is surely not needed.
    • Considering creating an enum type for your char types.
    • This method can be made static.
    • Consider using a switch statement instead of if (RequestedCharType == 1)
      &c.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a function that will clean a strings' special characters. I do NOT
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.