List of usage examples for java.lang Character isSurrogate
public static boolean isSurrogate(char ch)
From source file:Main.java
public static void main(String[] args) { for (char ch = Character.MIN_VALUE; ch < Character.MAX_VALUE; ch++) { if (Character.isSurrogate(ch)) { String s = String.format("\\u%04x", (int) ch); System.out.println(s); }// w w w . j a v a2 s . c o m } }
From source file:ddf.catalog.transformer.xml.EscapingPrintWriter.java
private static boolean isWellKnownCharacter(char c) { return Character.isDefined(c) && !Character.isISOControl(c) && !Character.isSurrogate(c); }
From source file:edu.cmu.cs.lti.discoursedb.github.converter.GithubConverterService.java
/** * Records the time a user did something associated with a repository * /* w w w .ja va2s. c o m*/ * @param fe Event object * @param users List of non-degenerate users * @param projects List of non-degenerate projects * public void mapUserCommitMessageEvent(GitHubCommitCommentEvent cce, Set<String> users, Set<String> projects) { // Only do this if EITHER the user OR the project are already in the database Discourse curDiscourse = getDiscourse("Github"); if ( users.contains(fe.getActor()) || projects.contains(fe.getProject()) ) { User curUser = ensureUserExists(fe.getActor(), users, curDiscourse); DiscoursePart projectDP = ensureProjectExists(fe.getProject(), projects, curDiscourse); DiscoursePartInteraction dpi = userService.createDiscoursePartInteraction(curUser, projectDP, DiscoursePartInteractionTypes.FORK_FROM); AnnotationInstance kind = annotationService.createTypedAnnotation("ForkedTo"); annotationService.addFeature(kind, annotationService.createTypedFeature(fe.getForkedTo(), "ForkedToProject")); dpi.setStartTime(fe.getCreatedAt()); } }*/ //From http://stackoverflow.com/questions/14981109/checking-utf-8-data-type-3-byte-or-4-byte-unicode public static boolean isEntirelyInBasicMultilingualPlane(String text) { if (text == null) { return true; } for (int i = 0; i < text.length(); i++) { if (Character.isSurrogate(text.charAt(i))) { return false; } } return true; }
From source file:com.denimgroup.threadfix.importer.impl.AbstractChannelImporter.java
private boolean isEntirelyInBasicMultilingualPlane(String text) { for (int i = 0; i < text.length(); i++) { if (Character.isSurrogate(text.charAt(i))) { return false; }/*from w ww. j a v a 2 s .c o m*/ } return true; }
From source file:com.android.calculator2.Calculator.java
/** * Add input characters to the end of the expression. * Map them to the appropriate button pushes when possible. Leftover characters * are added to mUnprocessedChars, which is presumed to immediately precede the newly * added characters./*from w ww. ja v a2s.co m*/ * @param moreChars Characters to be added. * @param explicit These characters were explicitly typed by the user, not pasted. */ private void addChars(String moreChars, boolean explicit) { if (mUnprocessedChars != null) { moreChars = mUnprocessedChars + moreChars; } int current = 0; int len = moreChars.length(); boolean lastWasDigit = false; if (mCurrentState == CalculatorState.RESULT && len != 0) { // Clear display immediately for incomplete function name. switchToInput(KeyMaps.keyForChar(moreChars.charAt(current))); } while (current < len) { char c = moreChars.charAt(current); int k = KeyMaps.keyForChar(c); if (!explicit) { int expEnd; if (lastWasDigit && current != (expEnd = Evaluator.exponentEnd(moreChars, current))) { // Process scientific notation with 'E' when pasting, in spite of ambiguity // with base of natural log. // Otherwise the 10^x key is the user's friend. mEvaluator.addExponent(moreChars, current, expEnd); current = expEnd; lastWasDigit = false; continue; } else { boolean isDigit = KeyMaps.digVal(k) != KeyMaps.NOT_DIGIT; if (current == 0 && (isDigit || k == R.id.dec_point) && mEvaluator.getExpr().hasTrailingConstant()) { // Refuse to concatenate pasted content to trailing constant. // This makes pasting of calculator results more consistent, whether or // not the old calculator instance is still around. addKeyToExpr(R.id.op_mul); } lastWasDigit = (isDigit || lastWasDigit && k == R.id.dec_point); } } if (k != View.NO_ID) { mCurrentButton = findViewById(k); if (explicit) { addExplicitKeyToExpr(k); } else { addKeyToExpr(k); } if (Character.isSurrogate(c)) { current += 2; } else { ++current; } continue; } int f = KeyMaps.funForString(moreChars, current); if (f != View.NO_ID) { mCurrentButton = findViewById(f); if (explicit) { addExplicitKeyToExpr(f); } else { addKeyToExpr(f); } if (f == R.id.op_sqrt) { // Square root entered as function; don't lose the parenthesis. addKeyToExpr(R.id.lparen); } current = moreChars.indexOf('(', current) + 1; continue; } // There are characters left, but we can't convert them to button presses. mUnprocessedChars = moreChars.substring(current); redisplayAfterFormulaChange(); return; } mUnprocessedChars = null; redisplayAfterFormulaChange(); }