Changeset 36c665a68f197cfe5edceffa0807e2b4e5275845
- Timestamp:
- 03/07/10 20:46:35 (3 years ago)
- Children:
- 52f513bb146e410efbdc3bc58f0ab3001d9ba77f
- Parents:
- 4beb0f8a3d942274015a4c700d470cf64bdc0c98
- git-committer:
- Matias De la Puente <mfpuente.ar@…> (03/07/10 20:46:35)
- Location:
- libi4uc
- Files:
-
- 1 added
- 2 edited
-
Makefile.am (modified) (1 diff)
-
i4ucdocument.vala (modified) (4 diffs)
-
i4ucencodings.vala (added)
Legend:
- Unmodified
- Added
- Removed
-
libi4uc/Makefile.am
r4beb0f8 r36c665a 42 42 i4ucdocumentsview.vala \ 43 43 i4ucdocumentsviewiface.vala \ 44 i4ucencodings.vala \ 44 45 i4ucfileslist.vala \ 45 46 i4ucitemscombo.vala \ -
libi4uc/i4ucdocument.vala
rc94fa49 r36c665a 70 70 } 71 71 72 public string encoding { set; get; default = "UTF-8"; } 73 72 74 public string load_contents (string uri) throws GLib.Error 73 75 { … … 79 81 _file = file; 80 82 this.etag = new_etag; 81 return contents; 83 string utf8_contents; 84 to_utf8 (contents, out utf8_contents); 85 return utf8_contents; 82 86 } 83 87 … … 89 93 else 90 94 file = _file; 91 var buffer = contents + "\n";95 var buffer = from_utf8 (contents + "\n"); 92 96 string new_etag; 93 97 string? etag = force_save ? null: _etag; … … 97 101 this.etag = new_etag; 98 102 } 103 104 private void to_utf8 (string encoded_string, out string utf8_string) throws GLib.ConvertError 105 { 106 foreach (var charset in Encodings.CHARSETS) 107 { 108 try 109 { 110 utf8_string = convert (encoded_string, (ssize_t)encoded_string.size (), "UTF-8", charset); 111 this.encoding = charset; 112 return; 113 } 114 catch (ConvertError e) 115 { 116 continue; 117 } 118 } 119 throw new GLib.ConvertError.FAILED (_("Error trying to convert the document to UTF-8")); 120 } 121 122 private string from_utf8 (string utf8_string) throws GLib.ConvertError 123 { 124 return convert (utf8_string, (ssize_t)utf8_string.size (), _encoding, "UTF-8"); 125 } 99 126 }
Note: See TracChangeset
for help on using the changeset viewer.

