java.nio.charset.Charset#aliases ( )源码实例Demo

下面列出了java.nio.charset.Charset#aliases ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: p4ic4idea   文件: InferFileTypeTest.java
/**
 * Test printout the JVM's supported charsets.
 */
@Test
public void testPrintoutSupportedCharsets() {
    SortedMap<String, Charset> charsetMap = Charset.availableCharsets();
    debugPrint("------------- availableCharsets ----------------");
    for (Map.Entry<String, Charset> entry : charsetMap.entrySet()) {
        String canonicalCharsetName = entry.getKey();
        debugPrint(canonicalCharsetName);
        Charset charset = entry.getValue();
        Set<String> aliases = charset.aliases();
        for (String alias : aliases) {
            debugPrint("\t" + alias);
        }
    }
    debugPrint("-----------------------------------------");
    String[] perforceCharsets = PerforceCharsets.getKnownCharsets();
    debugPrint("------------- perforceCharsets ----------------");
    for (String perforceCharset : perforceCharsets) {
        debugPrint(perforceCharset + " ... "
                + PerforceCharsets.getJavaCharsetName(perforceCharset));
    }
    debugPrint("-----------------------------------------");
    debugPrint("-----------------------------------------");
    debugPrint("Charset.defaultCharset().name(): " + Charset.defaultCharset().name());
    debugPrint("-----------------------------------------");
}
 
源代码2 项目: p4ic4idea   文件: InferFileTypeTest.java
/**
 * Test printout the JVM's supported charsets.
 */
@Test
public void testPrintoutSupportedCharsets() {
    SortedMap<String, Charset> charsetMap = Charset.availableCharsets();
    debugPrint("------------- availableCharsets ----------------");
    for (Map.Entry<String, Charset> entry : charsetMap.entrySet()) {
        String canonicalCharsetName = entry.getKey();
        debugPrint(canonicalCharsetName);
        Charset charset = entry.getValue();
        Set<String> aliases = charset.aliases();
        for (String alias : aliases) {
            debugPrint("\t" + alias);
        }
    }
    debugPrint("-----------------------------------------");
    String[] perforceCharsets = PerforceCharsets.getKnownCharsets();
    debugPrint("------------- perforceCharsets ----------------");
    for (String perforceCharset : perforceCharsets) {
        debugPrint(perforceCharset + " ... "
                + PerforceCharsets.getJavaCharsetName(perforceCharset));
    }
    debugPrint("-----------------------------------------");
    debugPrint("-----------------------------------------");
    debugPrint("Charset.defaultCharset().name(): " + Charset.defaultCharset().name());
    debugPrint("-----------------------------------------");
}
 
源代码3 项目: jaybird   文件: EncodingFactory.java
private void registerJavaMappingForEncodingDefinition(EncodingDefinition encodingDefinition) {
    final Charset charset = encodingDefinition.getJavaCharset();
    if (encodingDefinition.isInformationOnly() || encodingDefinition.isFirebirdOnly() || charset == null) {
        return;
    }
    final EncodingDefinition currentEncodingDefinition = javaCharsetToDefinition.get(charset);
    if (currentEncodingDefinition == null) {
        // Map Java charset to EncodingDefinition
        javaCharsetToDefinition.put(charset, encodingDefinition);
        javaAliasesToDefinition.put(charset.name().toLowerCase(), encodingDefinition);
        for (String charsetAlias : charset.aliases()) {
            javaAliasesToDefinition.put(charsetAlias.toLowerCase(), encodingDefinition);
        }
    } else if (log.isDebugEnabled()) {
        log.debug(String.format(
                "Not mapping java charset %s to Firebird encoding %s, already mapped to Firebird encoding %s",
                charset.name(), encodingDefinition.getEncoding(),
                currentEncodingDefinition.getFirebirdEncodingName()));
    }
}
 
源代码4 项目: lams   文件: CharsetMapping.java
public MysqlCharset(String charsetName, int mblen, int priority, String[] javaEncodings, ServerVersion minimumVersion) {
    this.charsetName = charsetName;
    this.mblen = mblen;
    this.priority = priority;

    for (int i = 0; i < javaEncodings.length; i++) {
        String encoding = javaEncodings[i];
        try {
            Charset cs = Charset.forName(encoding);
            addEncodingMapping(cs.name());

            Set<String> als = cs.aliases();
            Iterator<String> ali = als.iterator();
            while (ali.hasNext()) {
                addEncodingMapping(ali.next());
            }
        } catch (Exception e) {
            // if there is no support of this charset in JVM it's still possible to use our converter for 1-byte charsets
            if (mblen == 1) {
                addEncodingMapping(encoding);
            }
        }
    }

    if (this.javaEncodingsUc.size() == 0) {
        if (mblen > 1) {
            addEncodingMapping("UTF-8");
        } else {
            addEncodingMapping("Cp1252");
        }
    }

    this.minimumVersion = minimumVersion;
}
 
源代码5 项目: r-course   文件: CharsetMapping.java
/**
 * Constructs MysqlCharset object
 * 
 * @param charsetName
 *            MySQL charset name
 * @param mblen
 *            Max number of bytes per character
 * @param priority
 *            MysqlCharset with highest lever of this param will be used for Java encoding --> Mysql charsets conversion.
 * @param javaEncodings
 *            List of Java encodings corresponding to this MySQL charset; the first name in list is the default for mysql --> java data conversion
 */
public MysqlCharset(String charsetName, int mblen, int priority, String[] javaEncodings) {
    this.charsetName = charsetName;
    this.mblen = mblen;
    this.priority = priority;

    for (int i = 0; i < javaEncodings.length; i++) {
        String encoding = javaEncodings[i];
        try {
            Charset cs = Charset.forName(encoding);
            addEncodingMapping(cs.name());

            Set<String> als = cs.aliases();
            Iterator<String> ali = als.iterator();
            while (ali.hasNext()) {
                addEncodingMapping(ali.next());
            }
        } catch (Exception e) {
            // if there is no support of this charset in JVM it's still possible to use our converter for 1-byte charsets
            if (mblen == 1) {
                addEncodingMapping(encoding);
            }
        }
    }

    if (this.javaEncodingsUc.size() == 0) {
        if (mblen > 1) {
            addEncodingMapping("UTF-8");
        } else {
            addEncodingMapping("Cp1252");
        }
    }
}
 
源代码6 项目: Komondor   文件: CharsetMapping.java
/**
 * Constructs MysqlCharset object
 * 
 * @param charsetName
 *            MySQL charset name
 * @param mblen
 *            Max number of bytes per character
 * @param priority
 *            MysqlCharset with highest lever of this param will be used for Java encoding --> Mysql charsets conversion.
 * @param javaEncodings
 *            List of Java encodings corresponding to this MySQL charset; the first name in list is the default for mysql --> java data conversion
 */
public MysqlCharset(String charsetName, int mblen, int priority, String[] javaEncodings) {
    this.charsetName = charsetName;
    this.mblen = mblen;
    this.priority = priority;

    for (int i = 0; i < javaEncodings.length; i++) {
        String encoding = javaEncodings[i];
        try {
            Charset cs = Charset.forName(encoding);
            addEncodingMapping(cs.name());

            Set<String> als = cs.aliases();
            Iterator<String> ali = als.iterator();
            while (ali.hasNext()) {
                addEncodingMapping(ali.next());
            }
        } catch (Exception e) {
            // if there is no support of this charset in JVM it's still possible to use our converter for 1-byte charsets
            if (mblen == 1) {
                addEncodingMapping(encoding);
            }
        }
    }

    if (this.javaEncodingsUc.size() == 0) {
        if (mblen > 1) {
            addEncodingMapping("UTF-8");
        } else {
            addEncodingMapping("Cp1252");
        }
    }
}
 
源代码7 项目: FoxTelem   文件: CharsetMapping.java
public MysqlCharset(String charsetName, int mblen, int priority, String[] javaEncodings, ServerVersion minimumVersion) {
    this.charsetName = charsetName;
    this.mblen = mblen;
    this.priority = priority;

    for (int i = 0; i < javaEncodings.length; i++) {
        String encoding = javaEncodings[i];
        try {
            Charset cs = Charset.forName(encoding);
            addEncodingMapping(cs.name());

            Set<String> als = cs.aliases();
            Iterator<String> ali = als.iterator();
            while (ali.hasNext()) {
                addEncodingMapping(ali.next());
            }
        } catch (Exception e) {
            // if there is no support of this charset in JVM it's still possible to use our converter for 1-byte charsets
            if (mblen == 1) {
                addEncodingMapping(encoding);
            }
        }
    }

    if (this.javaEncodingsUc.size() == 0) {
        if (mblen > 1) {
            addEncodingMapping("UTF-8");
        } else {
            addEncodingMapping("Cp1252");
        }
    }

    this.minimumVersion = minimumVersion;
}
 
源代码8 项目: GreasySpoon   文件: MimeMagic.java
/**
 * Build up a list of all system available charsets 
 * @return hash table containing charsets names or aliases, associated to system charset 
 */
private static ConcurrentHashMap<String, String> fetchAvailableCharsets(){
	ConcurrentHashMap<String, String> charsetlist = new ConcurrentHashMap<String, String>();
    SortedMap<String, Charset> charsets = Charset.availableCharsets();
    Set<String> names = charsets.keySet();
    //if (debug>2) System.out.println("Available Charsets:");
    for (Iterator<String> e = names.iterator(); e.hasNext();) {
      String name = e.next().toLowerCase().trim();
      Charset charset = (Charset) charsets.get(name);
      if (name==null || charset== null) continue;
      name = name.trim();
      //if (debug>2) System.out.println(charset);
      charsetlist.put(name, name);
      Set<String> aliases = charset.aliases();
      
      for (Iterator<String> ee = aliases.iterator(); ee.hasNext();) {
    	  try{ 
    		  String charsetname = ee.next();
    		  if (charsetname==null || charsetname.equals("null")) continue;
    		  charsetlist.put(charsetname.toLowerCase().trim(), name);
    		  //if (debug>2) System.out.println("    " + charsetname);
    	  } catch (Exception e1){
    		  //if (debug>2) e1.printStackTrace();
    	  }
      }
    }
    return charsetlist;
  }
 
源代码9 项目: p4ic4idea   文件: SyncJapaneseFilesCharsetTest.java
/**
 * Test printout the JVM's supported charsets.
 */
@Test
public void testPrintoutSupportedCharsets() {
  SortedMap<String, Charset> charsetMap = Charset.availableCharsets();

  debugPrint("------------- availableCharsets ----------------");
  for (Map.Entry<String, Charset> entry : charsetMap.entrySet()) {
    String canonicalCharsetName = entry.getKey();
    debugPrint(canonicalCharsetName);
    Charset charset = entry.getValue();
    Set<String> aliases = charset.aliases();
    for (String alias : aliases) {
      debugPrint("\t" + alias);
    }
  }
  debugPrint("-----------------------------------------");

  String[] perforceCharsets = PerforceCharsets.getKnownCharsets();
  debugPrint("------------- perforceCharsets ----------------");
  for (String perforceCharset : perforceCharsets) {
    debugPrint(perforceCharset + " ... " + PerforceCharsets.getJavaCharsetName(perforceCharset));
  }
  debugPrint("-----------------------------------------");

  debugPrint("-----------------------------------------");
  debugPrint("Charset.defaultCharset().name(): " + Charset.defaultCharset().name());
  debugPrint("-----------------------------------------");
}
 
源代码10 项目: jaybird   文件: EncodingFactory.java
/**
 * Set of the charset name and aliases in lower case.
 *
 * @param charset Character set
 * @return Set of lower case names and aliases
 */
private static Set<String> toLowerCaseAliasSet(final Charset charset) {
    final Set<String> aliases = charset.aliases();
    final Set<String> potentialNames = new HashSet<>(aliases.size() + 1);
    potentialNames.add(charset.name().toLowerCase());
    for (String alias : aliases) {
        potentialNames.add(alias.toLowerCase());
    }
    return potentialNames;
}
 
源代码11 项目: p4ic4idea   文件: SyncJapaneseFilesCharsetTest.java
/**
 * Test printout the JVM's supported charsets.
 */
@Test
public void testPrintoutSupportedCharsets() {
  SortedMap<String, Charset> charsetMap = Charset.availableCharsets();

  debugPrint("------------- availableCharsets ----------------");
  for (Map.Entry<String, Charset> entry : charsetMap.entrySet()) {
    String canonicalCharsetName = entry.getKey();
    debugPrint(canonicalCharsetName);
    Charset charset = entry.getValue();
    Set<String> aliases = charset.aliases();
    for (String alias : aliases) {
      debugPrint("\t" + alias);
    }
  }
  debugPrint("-----------------------------------------");

  String[] perforceCharsets = PerforceCharsets.getKnownCharsets();
  debugPrint("------------- perforceCharsets ----------------");
  for (String perforceCharset : perforceCharsets) {
    debugPrint(perforceCharset + " ... " + PerforceCharsets.getJavaCharsetName(perforceCharset));
  }
  debugPrint("-----------------------------------------");

  debugPrint("-----------------------------------------");
  debugPrint("Charset.defaultCharset().name(): " + Charset.defaultCharset().name());
  debugPrint("-----------------------------------------");
}
 
源代码12 项目: Tomcat8-Source-Read   文件: CharsetCache.java
private void addToCache(String name, Charset charset) {
    cache.put(name, charset);
    for (String alias : charset.aliases()) {
        cache.put(alias.toLowerCase(Locale.ENGLISH), charset);
    }
}
 
源代码13 项目: p4ic4idea   文件: SyncUtf16beFilesWinLocalTest.java
/**
 * Test sync utf16-le encoded files: UTF-16LE BOM: ff fe
 */
@Test
public void testSyncUtf16leFiles() {
	String depotFile = null;

	try {
		IClient client = server.getClient("p4TestUserWS20112Windows");
		server.setCurrentClient(client);
		SortedMap<String, Charset> charsetMap = Charset.availableCharsets();

		debugPrint("------------- availableCharsets ----------------");
		for (Map.Entry<String, Charset> entry : charsetMap.entrySet()) {
			String canonicalCharsetName = entry.getKey();
			debugPrint(canonicalCharsetName);
			Charset charset = entry.getValue();
			Set<String> aliases = charset.aliases();
			for (String alias : aliases) {
				debugPrint("\t" + alias);
			}
		}
		debugPrint("-----------------------------------------");

		String[] perforceCharsets = PerforceCharsets.getKnownCharsets();
		debugPrint("------------- perforceCharsets ----------------");
		for (String perforceCharset : perforceCharsets) {
			debugPrint(perforceCharset + " ... "
					+ PerforceCharsets.getJavaCharsetName(perforceCharset));
		}
		debugPrint("-----------------------------------------");

		debugPrint("-----------------------------------------");
		debugPrint("Charset.defaultCharset().name(): "
				+ Charset.defaultCharset().name());
		debugPrint("-----------------------------------------");
		
		
		depotFile = "//depot/152Bugs/utf16-be/utf16-be.xbit";

		List<IFileSpec> files = client.sync(
				FileSpecBuilder.makeFileSpecList(depotFile),
				new SyncOptions().setForceUpdate(true));
		assertNotNull(files);

	} catch (P4JavaException e) {
		fail("Unexpected exception: " + e.getLocalizedMessage());
	}
}
 
源代码14 项目: p4ic4idea   文件: SyncUtf16leFilesTest.java
/**
 * Test sync utf16-le encoded files: UTF-16LE BOM: ff fe
 */
@Test
public void testSyncUtf16leFiles() {
	String depotFile = null;

	try {
		IClient client = server.getClient("p4TestUserWSMac");
		assertNotNull(client);
		server.setCurrentClient(client);
		SortedMap<String, Charset> charsetMap = Charset.availableCharsets();

		debugPrint("------------- availableCharsets ----------------");
		for (Map.Entry<String, Charset> entry : charsetMap.entrySet()) {
			String canonicalCharsetName = entry.getKey();
			debugPrint(canonicalCharsetName);
			Charset charset = entry.getValue();
			Set<String> aliases = charset.aliases();
			for (String alias : aliases) {
				debugPrint("\t" + alias);
			}
		}
		debugPrint("-----------------------------------------");

		String[] perforceCharsets = PerforceCharsets.getKnownCharsets();
		debugPrint("------------- perforceCharsets ----------------");
		for (String perforceCharset : perforceCharsets) {
			debugPrint(perforceCharset + " ... "
					+ PerforceCharsets.getJavaCharsetName(perforceCharset));
		}
		debugPrint("-----------------------------------------");

		debugPrint("-----------------------------------------");
		debugPrint("Charset.defaultCharset().name(): "
				+ Charset.defaultCharset().name());
		debugPrint("-----------------------------------------");
		
		
		depotFile = "//depot/152Bugs/utf16-le/utf16-le_test.txt";

		List<IFileSpec> files = client.sync(
				FileSpecBuilder.makeFileSpecList(depotFile),
				new SyncOptions().setForceUpdate(true));
		assertNotNull(files);

	} catch (P4JavaException e) {
		fail("Unexpected exception: " + e.getLocalizedMessage());
	}
}
 
源代码15 项目: p4ic4idea   文件: SyncUtf16beFilesWinLocalTest.java
/**
 * Test sync utf16-le encoded files: UTF-16LE BOM: ff fe
 */
@Test
public void testSyncUtf16leFiles() {
	String depotFile = null;

	try {
		IClient client = server.getClient("p4TestUserWS20112Windows");
		server.setCurrentClient(client);
		SortedMap<String, Charset> charsetMap = Charset.availableCharsets();

		debugPrint("------------- availableCharsets ----------------");
		for (Map.Entry<String, Charset> entry : charsetMap.entrySet()) {
			String canonicalCharsetName = entry.getKey();
			debugPrint(canonicalCharsetName);
			Charset charset = entry.getValue();
			Set<String> aliases = charset.aliases();
			for (String alias : aliases) {
				debugPrint("\t" + alias);
			}
		}
		debugPrint("-----------------------------------------");

		String[] perforceCharsets = PerforceCharsets.getKnownCharsets();
		debugPrint("------------- perforceCharsets ----------------");
		for (String perforceCharset : perforceCharsets) {
			debugPrint(perforceCharset + " ... "
					+ PerforceCharsets.getJavaCharsetName(perforceCharset));
		}
		debugPrint("-----------------------------------------");

		debugPrint("-----------------------------------------");
		debugPrint("Charset.defaultCharset().name(): "
				+ Charset.defaultCharset().name());
		debugPrint("-----------------------------------------");
		
		
		depotFile = "//depot/152Bugs/utf16-be/utf16-be.xbit";

		List<IFileSpec> files = client.sync(
				FileSpecBuilder.makeFileSpecList(depotFile),
				new SyncOptions().setForceUpdate(true));
		assertNotNull(files);

	} catch (P4JavaException e) {
		fail("Unexpected exception: " + e.getLocalizedMessage());
	}
}
 
源代码16 项目: p4ic4idea   文件: SyncUtf16leFilesTest.java
/**
 * Test sync utf16-le encoded files: UTF-16LE BOM: ff fe
 */
@Test
public void testSyncUtf16leFiles() {
	String depotFile = null;

	try {
		IClient client = server.getClient("p4TestUserWSMac");
		assertNotNull(client);
		server.setCurrentClient(client);
		SortedMap<String, Charset> charsetMap = Charset.availableCharsets();

		debugPrint("------------- availableCharsets ----------------");
		for (Map.Entry<String, Charset> entry : charsetMap.entrySet()) {
			String canonicalCharsetName = entry.getKey();
			debugPrint(canonicalCharsetName);
			Charset charset = entry.getValue();
			Set<String> aliases = charset.aliases();
			for (String alias : aliases) {
				debugPrint("\t" + alias);
			}
		}
		debugPrint("-----------------------------------------");

		String[] perforceCharsets = PerforceCharsets.getKnownCharsets();
		debugPrint("------------- perforceCharsets ----------------");
		for (String perforceCharset : perforceCharsets) {
			debugPrint(perforceCharset + " ... "
					+ PerforceCharsets.getJavaCharsetName(perforceCharset));
		}
		debugPrint("-----------------------------------------");

		debugPrint("-----------------------------------------");
		debugPrint("Charset.defaultCharset().name(): "
				+ Charset.defaultCharset().name());
		debugPrint("-----------------------------------------");
		
		
		depotFile = "//depot/152Bugs/utf16-le/utf16-le_test.txt";

		List<IFileSpec> files = client.sync(
				FileSpecBuilder.makeFileSpecList(depotFile),
				new SyncOptions().setForceUpdate(true));
		assertNotNull(files);

	} catch (P4JavaException e) {
		fail("Unexpected exception: " + e.getLocalizedMessage());
	}
}
 
源代码17 项目: p4ic4idea   文件: SyncUtf16beFilesWinLocalTest.java
/**
 * Test sync utf16-le encoded files: UTF-16LE BOM: ff fe
 */
@Test
public void testSyncUtf16leFiles() {
	String depotFile = null;

	try {
		IClient client = server.getClient("p4TestUserWS20112Windows");
		server.setCurrentClient(client);
		SortedMap<String, Charset> charsetMap = Charset.availableCharsets();

		debugPrint("------------- availableCharsets ----------------");
		for (Map.Entry<String, Charset> entry : charsetMap.entrySet()) {
			String canonicalCharsetName = entry.getKey();
			debugPrint(canonicalCharsetName);
			Charset charset = entry.getValue();
			Set<String> aliases = charset.aliases();
			for (String alias : aliases) {
				debugPrint("\t" + alias);
			}
		}
		debugPrint("-----------------------------------------");

		String[] perforceCharsets = PerforceCharsets.getKnownCharsets();
		debugPrint("------------- perforceCharsets ----------------");
		for (String perforceCharset : perforceCharsets) {
			debugPrint(perforceCharset + " ... "
					+ PerforceCharsets.getJavaCharsetName(perforceCharset));
		}
		debugPrint("-----------------------------------------");

		debugPrint("-----------------------------------------");
		debugPrint("Charset.defaultCharset().name(): "
				+ Charset.defaultCharset().name());
		debugPrint("-----------------------------------------");
		
		
		depotFile = "//depot/152Bugs/utf16-be/utf16-be.xbit";

		List<IFileSpec> files = client.sync(
				FileSpecBuilder.makeFileSpecList(depotFile),
				new SyncOptions().setForceUpdate(true));
		assertNotNull(files);

	} catch (P4JavaException e) {
		fail("Unexpected exception: " + e.getLocalizedMessage());
	}
}
 
源代码18 项目: p4ic4idea   文件: SyncUtf16leFilesTest.java
/**
 * Test sync utf16-le encoded files: UTF-16LE BOM: ff fe
 */
@Test
public void testSyncUtf16leFiles() {
	String depotFile = null;

	try {
		IClient client = server.getClient("p4TestUserWSMac");
		assertNotNull(client);
		server.setCurrentClient(client);
		SortedMap<String, Charset> charsetMap = Charset.availableCharsets();

		debugPrint("------------- availableCharsets ----------------");
		for (Map.Entry<String, Charset> entry : charsetMap.entrySet()) {
			String canonicalCharsetName = entry.getKey();
			debugPrint(canonicalCharsetName);
			Charset charset = entry.getValue();
			Set<String> aliases = charset.aliases();
			for (String alias : aliases) {
				debugPrint("\t" + alias);
			}
		}
		debugPrint("-----------------------------------------");

		String[] perforceCharsets = PerforceCharsets.getKnownCharsets();
		debugPrint("------------- perforceCharsets ----------------");
		for (String perforceCharset : perforceCharsets) {
			debugPrint(perforceCharset + " ... "
					+ PerforceCharsets.getJavaCharsetName(perforceCharset));
		}
		debugPrint("-----------------------------------------");

		debugPrint("-----------------------------------------");
		debugPrint("Charset.defaultCharset().name(): "
				+ Charset.defaultCharset().name());
		debugPrint("-----------------------------------------");
		
		
		depotFile = "//depot/152Bugs/utf16-le/utf16-le_test.txt";

		List<IFileSpec> files = client.sync(
				FileSpecBuilder.makeFileSpecList(depotFile),
				new SyncOptions().setForceUpdate(true));
		assertNotNull(files);

	} catch (P4JavaException e) {
		fail("Unexpected exception: " + e.getLocalizedMessage());
	}
}
 
源代码19 项目: p4ic4idea   文件: SyncUtf16beFilesWinLocalTest.java
/**
 * Test sync utf16-le encoded files: UTF-16LE BOM: ff fe
 */
@Test
public void testSyncUtf16leFiles() {
	String depotFile = null;

	try {
		IClient client = server.getClient("p4TestUserWS20112Windows");
		server.setCurrentClient(client);
		SortedMap<String, Charset> charsetMap = Charset.availableCharsets();

		debugPrint("------------- availableCharsets ----------------");
		for (Map.Entry<String, Charset> entry : charsetMap.entrySet()) {
			String canonicalCharsetName = entry.getKey();
			debugPrint(canonicalCharsetName);
			Charset charset = entry.getValue();
			Set<String> aliases = charset.aliases();
			for (String alias : aliases) {
				debugPrint("\t" + alias);
			}
		}
		debugPrint("-----------------------------------------");

		String[] perforceCharsets = PerforceCharsets.getKnownCharsets();
		debugPrint("------------- perforceCharsets ----------------");
		for (String perforceCharset : perforceCharsets) {
			debugPrint(perforceCharset + " ... "
					+ PerforceCharsets.getJavaCharsetName(perforceCharset));
		}
		debugPrint("-----------------------------------------");

		debugPrint("-----------------------------------------");
		debugPrint("Charset.defaultCharset().name(): "
				+ Charset.defaultCharset().name());
		debugPrint("-----------------------------------------");
		
		
		depotFile = "//depot/152Bugs/utf16-be/utf16-be.xbit";

		List<IFileSpec> files = client.sync(
				FileSpecBuilder.makeFileSpecList(depotFile),
				new SyncOptions().setForceUpdate(true));
		assertNotNull(files);

	} catch (P4JavaException e) {
		fail("Unexpected exception: " + e.getLocalizedMessage());
	}
}
 
源代码20 项目: p4ic4idea   文件: SyncUtf16leFilesTest.java
/**
 * Test sync utf16-le encoded files: UTF-16LE BOM: ff fe
 */
@Test
public void testSyncUtf16leFiles() {
	String depotFile = null;

	try {
		IClient client = server.getClient("p4TestUserWSMac");
		assertNotNull(client);
		server.setCurrentClient(client);
		SortedMap<String, Charset> charsetMap = Charset.availableCharsets();

		debugPrint("------------- availableCharsets ----------------");
		for (Map.Entry<String, Charset> entry : charsetMap.entrySet()) {
			String canonicalCharsetName = entry.getKey();
			debugPrint(canonicalCharsetName);
			Charset charset = entry.getValue();
			Set<String> aliases = charset.aliases();
			for (String alias : aliases) {
				debugPrint("\t" + alias);
			}
		}
		debugPrint("-----------------------------------------");

		String[] perforceCharsets = PerforceCharsets.getKnownCharsets();
		debugPrint("------------- perforceCharsets ----------------");
		for (String perforceCharset : perforceCharsets) {
			debugPrint(perforceCharset + " ... "
					+ PerforceCharsets.getJavaCharsetName(perforceCharset));
		}
		debugPrint("-----------------------------------------");

		debugPrint("-----------------------------------------");
		debugPrint("Charset.defaultCharset().name(): "
				+ Charset.defaultCharset().name());
		debugPrint("-----------------------------------------");
		
		
		depotFile = "//depot/152Bugs/utf16-le/utf16-le_test.txt";

		List<IFileSpec> files = client.sync(
				FileSpecBuilder.makeFileSpecList(depotFile),
				new SyncOptions().setForceUpdate(true));
		assertNotNull(files);

	} catch (P4JavaException e) {
		fail("Unexpected exception: " + e.getLocalizedMessage());
	}
}