mirror of
				https://github.com/AppFlowy-IO/AppFlowy.git
				synced 2025-11-04 12:03:28 +00:00 
			
		
		
		
	* chore: update editor version * fix: export name (with CJK) doesn't match the document name * chore: bump version 0.3.1
		
			
				
	
	
		
			21 lines
		
	
	
		
			554 B
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			21 lines
		
	
	
		
			554 B
		
	
	
	
		
			Dart
		
	
	
	
	
	
import 'package:flutter/material.dart';
 | 
						|
 | 
						|
extension EncodeString on String {
 | 
						|
  static const _specialCharacters = r'\/:*?"<>| ';
 | 
						|
 | 
						|
  /// Encode a string to a file name.
 | 
						|
  ///
 | 
						|
  /// Normalizes the string to remove special characters and replaces the "\/:*?"<>|" with underscores.
 | 
						|
  String toFileName() {
 | 
						|
    final buffer = StringBuffer();
 | 
						|
    for (final character in characters) {
 | 
						|
      if (_specialCharacters.contains(character)) {
 | 
						|
        buffer.write('_');
 | 
						|
      } else {
 | 
						|
        buffer.write(character);
 | 
						|
      }
 | 
						|
    }
 | 
						|
    return buffer.toString();
 | 
						|
  }
 | 
						|
}
 |