Java Char Convert To convertChar(char c)

Here you can find the source of convertChar(char c)

Description

convert Char

License

Open Source License

Declaration

private static int convertChar(char c) 

Method Source Code

//package com.java2s;
/*//ww w. j  a v a  2  s  .c om
 * StringUtils.java
 *
 * Copyright (c) 1998 - 2006 BusinessTechnology, Ltd.
 * All rights reserved
 *
 * This program is the proprietary and confidential information
 * of BusinessTechnology, Ltd. and may be used and disclosed only
 * as authorized in a license agreement authorizing and
 * controlling such use and disclosure
 *
 * Millennium ERP system.
 *
 */

public class Main {
    private static int convertChar(char c) {
        if ('0' <= c && c <= '9') {
            return c - '0';
        } else if ('a' <= c && c <= 'f') {
            return c - 'a' + 0xa;
        } else if ('A' <= c && c <= 'F') {
            return c - 'A' + 0xa;
        } else {
            throw new IllegalArgumentException("Invalid hex character: " + c);
        }
    }
}

Related

  1. charToNCRef(int c)
  2. charToNum(char c)
  3. charToNybble(char c)
  4. charToOctet(char c)
  5. charToUpperOrLower(String string, int pos, boolean upper)
  6. convertCharacter(final String value)
  7. convertCharacterEntity(String value)
  8. convertCharacterOffsetToCodePointOffset(String inputStr, int charOffset)
  9. convertCharacters(String fileName)