<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -41,6 +41,8 @@
 - (void)navToTOC:(id)sender;
 - (void)navToIDX:(id)sender;
 
+- (void)settingSaved;
+
 - (IBAction)toggleFullScreen:(id)sender;
 - (IBAction)toggleScaleToFit:(id)sender;
 - (IBAction)goHome:(id)sender;</diff>
      <filename>Classes/CHMBrowserController.h</filename>
    </modified>
    <modified>
      <diff>@@ -178,6 +178,10 @@
     [webView reload];
 }
 
+- (void)settingSaved
+{
+    [webView reload];
+}
 #pragma mark load page
 - (void)loadPath:(NSString *)path
 {
@@ -188,9 +192,7 @@
 - (void)loadURL:(NSURL *)url
 {
 	if( url ) {
-		CHMDocument *doc = [CHMDocument CurrentDocument];
-		NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
-		[req setEncodingName:[doc currentEncodingName]];
+		NSURLRequest *req = [NSURLRequest requestWithURL:url];
 		[webView loadRequest:req];
 	}
 }
@@ -398,6 +400,7 @@
     DocumentSettingController *controller = [[DocumentSettingController alloc]
                                              initWithNibName:@&quot;DocumentSetting&quot; bundle:nil];
     [self.navigationController pushViewController:controller animated:YES];
+    controller.delegate = self;
     [controller release];
 }
 #pragma mark dealloc</diff>
      <filename>Classes/CHMBrowserController.m</filename>
    </modified>
    <modified>
      <diff>@@ -265,6 +265,7 @@ static CHMDocument *currentDocument = nil;
 {
     tocSource = nil;
     zoomFactor = 1;
+    encodingName = [self getPrefForKey:@&quot;text_encoding&quot; withDefault:nil];
     return self;
 }
 
@@ -473,7 +474,9 @@ static CHMDocument *currentDocument = nil;
 			{
 				unsigned int lcid = readLong(systemData, offset + 4);
 				NSLog(@&quot;SYSTEM LCID: %d&quot;, lcid);
-				encodingName = LCIDtoEncodingName(lcid);
+                if (nil == encodingName || [encodingName length] == 0) {
+                    encodingName = LCIDtoEncodingName(lcid);
+                }
 				NSLog(@&quot;SYSTEM encoding: %@&quot;, encodingName);
 			}
 				break;
@@ -557,6 +560,10 @@ static CHMDocument *currentDocument = nil;
 #pragma mark encoding
 - (NSString*)currentEncodingName
 {
+    NSString *name = [self getPrefForKey:@&quot;text_encoding&quot; withDefault:nil];
+    if (nil != name &amp;&amp; [name length] &gt; 0) {
+        return name;
+    }
 	return encodingName;
 }
 </diff>
      <filename>Classes/CHMDocument.m</filename>
    </modified>
    <modified>
      <diff>@@ -7,12 +7,16 @@
 //
 
 #import &lt;UIKit/UIKit.h&gt;
-
+@class CHMBrowserController;
 
 @interface DocumentSettingController : UITableViewController {
     IBOutlet UITableViewCell    *textEncodingCell;
-    
     IBOutlet UITextField        *textEncodingField;
+    
+    CHMBrowserController *delegate;
 }
 
+@property (nonatomic, assign) CHMBrowserController *delegate;
+
+- (void)settingChanged:(id)sender;
 @end</diff>
      <filename>Classes/DocumentSettingController.h</filename>
    </modified>
    <modified>
      <diff>@@ -8,11 +8,14 @@
 
 #import &quot;CHMDocument.h&quot;
 #import &quot;TextEncodingController.h&quot;
+#import &quot;CHMBrowserController.h&quot;
 #import &quot;DocumentSettingController.h&quot;
 
 
 @implementation DocumentSettingController
 
+@synthesize delegate;
+
 /*
 - (id)initWithStyle:(UITableViewStyle)style {
     // Override initWithStyle: if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
@@ -85,7 +88,7 @@
 
 
 // Customize the appearance of table view cells.
-- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
+- (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
 
     if (indexPath.row == 0) {
         textEncodingField.text = [[CHMDocument CurrentDocument] getPrefForKey:@&quot;text_encoding&quot; withDefault:@&quot;Default&quot;];
@@ -97,11 +100,12 @@
 }
 
 
-- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
+- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
     TextEncodingController *controller = [[TextEncodingController alloc] initWithStyle:UITableViewStyleGrouped];
     [self.navigationController pushViewController:controller animated:YES];
+    controller.settingController = self;
     [controller release];
-    [tableView deselectRowAtIndexPath:indexPath animated:NO];
+    [aTableView deselectRowAtIndexPath:indexPath animated:NO];
     // Navigation logic may go here. Create and push another view controller.
 	// AnotherViewController *anotherViewController = [[AnotherViewController alloc] initWithNibName:@&quot;AnotherView&quot; bundle:nil];
 	// [self.navigationController pushViewController:anotherViewController];
@@ -147,7 +151,12 @@
     return YES;
 }
 */
-
+- (void)settingChanged:(id)sender
+{
+    if (nil != delegate)
+        [delegate settingSaved];
+    [(UITableView*)self.view reloadData];
+}
 
 - (void)dealloc {
     [super dealloc];</diff>
      <filename>Classes/DocumentSettingController.m</filename>
    </modified>
    <modified>
      <diff>@@ -12,15 +12,4 @@
 @interface ITSSProtocol : NSURLProtocol {
 
 }
-@end
-
-@interface NSURLRequest (ITSSProtocol)
-- (CHMDocument *)chmDoc;
-- (NSString *)encodingName;
-@end
-
-@interface NSMutableURLRequest (ITSSProtocol)
-- (void)setChmDoc:(CHMDocument *)doc;
-- (void)setEncodingName:(NSString *)name;
-@end
-
+@end
\ No newline at end of file</diff>
      <filename>Classes/ITSSProtocol.h</filename>
    </modified>
    <modified>
      <diff>@@ -37,7 +37,7 @@
 {
     NSURL *url = [[self request] URL];
 	CHMDocument *doc = [CHMDocument CurrentDocument];
-	NSString *encoding = [[self request] encodingName];
+	NSString *encoding = [doc currentEncodingName];
 	
 	if( !doc ) {
 		[[self client] URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:0 userInfo:nil]];
@@ -81,22 +81,4 @@
     [response release];	
 }
 
-@end
-
-@implementation NSURLRequest (SpecialProtocol)
-
-- (NSString *)encodingName
-{
-	return [NSURLProtocol propertyForKey:@&quot;encoding&quot; inRequest:self];
-}
-@end
-
-
-
-@implementation NSMutableURLRequest (SpecialProtocol)
-
-- (void)setEncodingName:(NSString *)name
-{
-	[NSURLProtocol setProperty:name forKey:@&quot;encoding&quot; inRequest:self];
-}
 @end
\ No newline at end of file</diff>
      <filename>Classes/ITSSProtocol.m</filename>
    </modified>
    <modified>
      <diff>@@ -7,10 +7,12 @@
 //
 
 #import &lt;UIKit/UIKit.h&gt;
-
+@class DocumentSettingController;
 
 @interface TextEncodingController : UITableViewController {
     NSArray *encodingNames;
+    DocumentSettingController *settingController;
 }
 
+@property (nonatomic, assign) DocumentSettingController * settingController;
 @end</diff>
      <filename>Classes/TextEncodingController.h</filename>
    </modified>
    <modified>
      <diff>@@ -7,11 +7,12 @@
 //
 
 #import &quot;CHMDocument.h&quot;
+#import &quot;DocumentSettingController.h&quot;
 #import &quot;TextEncodingController.h&quot;
 
 
 @implementation TextEncodingController
-
+@synthesize settingController;
 /*
 - (id)initWithStyle:(UITableViewStyle)style {
     // Override initWithStyle: if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
@@ -122,6 +123,7 @@
     NSString *encodingName = [[[encodingNames objectAtIndex:indexPath.section] objectAtIndex:indexPath.row] objectForKey:@&quot;name&quot;];
     if (encodingName &amp;&amp; [encodingName length] &gt; 0) {
         [[CHMDocument CurrentDocument] setPref:encodingName forKey:@&quot;text_encoding&quot;];
+        [settingController settingChanged:self];
     }
     [tableView deselectRowAtIndexPath:indexPath animated:NO];
     [self.navigationController popViewControllerAnimated:YES];</diff>
      <filename>Classes/TextEncodingController.m</filename>
    </modified>
    <modified>
      <diff>@@ -8,8 +8,8 @@
 		&lt;string key=&quot;IBDocument.HIToolboxVersion&quot;&gt;353.00&lt;/string&gt;
 		&lt;object class=&quot;NSMutableArray&quot; key=&quot;IBDocument.EditedObjectIDs&quot;&gt;
 			&lt;bool key=&quot;EncodedWithXMLCoder&quot;&gt;YES&lt;/bool&gt;
-			&lt;integer value=&quot;9&quot;/&gt;
 			&lt;integer value=&quot;3&quot;/&gt;
+			&lt;integer value=&quot;9&quot;/&gt;
 		&lt;/object&gt;
 		&lt;object class=&quot;NSArray&quot; key=&quot;IBDocument.PluginDependencies&quot;&gt;
 			&lt;bool key=&quot;EncodedWithXMLCoder&quot;&gt;YES&lt;/bool&gt;
@@ -296,7 +296,7 @@
 				&lt;/object&gt;
 			&lt;/object&gt;
 			&lt;nil key=&quot;sourceID&quot;/&gt;
-			&lt;int key=&quot;maxID&quot;&gt;13&lt;/int&gt;
+			&lt;int key=&quot;maxID&quot;&gt;15&lt;/int&gt;
 		&lt;/object&gt;
 		&lt;object class=&quot;IBClassDescriber&quot; key=&quot;IBDocument.Classes&quot;&gt;
 			&lt;object class=&quot;NSMutableArray&quot; key=&quot;referencedPartialClassDescriptions&quot;&gt;
@@ -304,6 +304,10 @@
 				&lt;object class=&quot;IBPartialClassDescription&quot;&gt;
 					&lt;string key=&quot;className&quot;&gt;DocumentSettingController&lt;/string&gt;
 					&lt;string key=&quot;superclassName&quot;&gt;UITableViewController&lt;/string&gt;
+					&lt;object class=&quot;NSMutableDictionary&quot; key=&quot;actions&quot;&gt;
+						&lt;string key=&quot;NS.key.0&quot;&gt;settingChanged:&lt;/string&gt;
+						&lt;string key=&quot;NS.object.0&quot;&gt;id&lt;/string&gt;
+					&lt;/object&gt;
 					&lt;object class=&quot;NSMutableDictionary&quot; key=&quot;outlets&quot;&gt;
 						&lt;bool key=&quot;EncodedWithXMLCoder&quot;&gt;YES&lt;/bool&gt;
 						&lt;object class=&quot;NSMutableArray&quot; key=&quot;dict.sortedKeys&quot;&gt;</diff>
      <filename>DocumentSetting.xib</filename>
    </modified>
    <modified>
      <diff>@@ -123,39 +123,40 @@
 								&lt;float key=&quot;IBUIWidth&quot;&gt;3.200000e+01&lt;/float&gt;
 								&lt;reference key=&quot;IBUIToolbar&quot; ref=&quot;241411469&quot;/&gt;
 							&lt;/object&gt;
-							&lt;object class=&quot;IBUIBarButtonItem&quot; id=&quot;113258795&quot;&gt;
+							&lt;object class=&quot;IBUIBarButtonItem&quot; id=&quot;1068126399&quot;&gt;
 								&lt;int key=&quot;IBUISystemItemIdentifier&quot;&gt;5&lt;/int&gt;
 								&lt;reference key=&quot;IBUIToolbar&quot; ref=&quot;241411469&quot;/&gt;
 							&lt;/object&gt;
-							&lt;object class=&quot;IBUIBarButtonItem&quot; id=&quot;91225355&quot;&gt;
+							&lt;object class=&quot;IBUIBarButtonItem&quot; id=&quot;2356769&quot;&gt;
 								&lt;object class=&quot;NSCustomResource&quot; key=&quot;IBUIImage&quot;&gt;
 									&lt;string key=&quot;NSClassName&quot;&gt;NSImage&lt;/string&gt;
-									&lt;string key=&quot;NSResourceName&quot;&gt;zoomtofit.png&lt;/string&gt;
+									&lt;string key=&quot;NSResourceName&quot;&gt;option.png&lt;/string&gt;
 								&lt;/object&gt;
 								&lt;float key=&quot;IBUIWidth&quot;&gt;3.200000e+01&lt;/float&gt;
 								&lt;reference key=&quot;IBUIToolbar&quot; ref=&quot;241411469&quot;/&gt;
 							&lt;/object&gt;
-							&lt;object class=&quot;IBUIBarButtonItem&quot; id=&quot;628367794&quot;&gt;
+							&lt;object class=&quot;IBUIBarButtonItem&quot; id=&quot;113258795&quot;&gt;
 								&lt;int key=&quot;IBUISystemItemIdentifier&quot;&gt;5&lt;/int&gt;
 								&lt;reference key=&quot;IBUIToolbar&quot; ref=&quot;241411469&quot;/&gt;
 							&lt;/object&gt;
-							&lt;object class=&quot;IBUIBarButtonItem&quot; id=&quot;992970946&quot;&gt;
+							&lt;object class=&quot;IBUIBarButtonItem&quot; id=&quot;91225355&quot;&gt;
 								&lt;object class=&quot;NSCustomResource&quot; key=&quot;IBUIImage&quot;&gt;
 									&lt;string key=&quot;NSClassName&quot;&gt;NSImage&lt;/string&gt;
-									&lt;string key=&quot;NSResourceName&quot;&gt;fullscreen.png&lt;/string&gt;
+									&lt;string key=&quot;NSResourceName&quot;&gt;zoomtofit.png&lt;/string&gt;
 								&lt;/object&gt;
 								&lt;float key=&quot;IBUIWidth&quot;&gt;3.200000e+01&lt;/float&gt;
 								&lt;reference key=&quot;IBUIToolbar&quot; ref=&quot;241411469&quot;/&gt;
 							&lt;/object&gt;
-							&lt;object class=&quot;IBUIBarButtonItem&quot; id=&quot;1068126399&quot;&gt;
+							&lt;object class=&quot;IBUIBarButtonItem&quot; id=&quot;628367794&quot;&gt;
 								&lt;int key=&quot;IBUISystemItemIdentifier&quot;&gt;5&lt;/int&gt;
 								&lt;reference key=&quot;IBUIToolbar&quot; ref=&quot;241411469&quot;/&gt;
 							&lt;/object&gt;
-							&lt;object class=&quot;IBUIBarButtonItem&quot; id=&quot;2356769&quot;&gt;
+							&lt;object class=&quot;IBUIBarButtonItem&quot; id=&quot;992970946&quot;&gt;
 								&lt;object class=&quot;NSCustomResource&quot; key=&quot;IBUIImage&quot;&gt;
 									&lt;string key=&quot;NSClassName&quot;&gt;NSImage&lt;/string&gt;
-									&lt;string key=&quot;NSResourceName&quot;&gt;option.png&lt;/string&gt;
+									&lt;string key=&quot;NSResourceName&quot;&gt;fullscreen.png&lt;/string&gt;
 								&lt;/object&gt;
+								&lt;float key=&quot;IBUIWidth&quot;&gt;3.200000e+01&lt;/float&gt;
 								&lt;reference key=&quot;IBUIToolbar&quot; ref=&quot;241411469&quot;/&gt;
 							&lt;/object&gt;
 						&lt;/object&gt;
@@ -614,7 +615,7 @@
 				&lt;/object&gt;
 			&lt;/object&gt;
 			&lt;nil key=&quot;sourceID&quot;/&gt;
-			&lt;int key=&quot;maxID&quot;&gt;59&lt;/int&gt;
+			&lt;int key=&quot;maxID&quot;&gt;61&lt;/int&gt;
 		&lt;/object&gt;
 		&lt;object class=&quot;IBClassDescriber&quot; key=&quot;IBDocument.Classes&quot;&gt;
 			&lt;object class=&quot;NSMutableArray&quot; key=&quot;referencedPartialClassDescriptions&quot;&gt;</diff>
      <filename>English.lproj/CHMBrowser.xib</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>95475bd6cad9e1c18a084f3588bb9b6aee285f2c</id>
    </parent>
  </parents>
  <author>
    <name>Robin Lu</name>
    <email>iamawalrus@gmail.com</email>
  </author>
  <url>http://github.com/robin/ichm-m/commit/bf4d09f21e83837dda566500c083844c86db1ac5</url>
  <id>bf4d09f21e83837dda566500c083844c86db1ac5</id>
  <committed-date>2009-03-30T07:54:22-07:00</committed-date>
  <authored-date>2009-03-30T07:54:22-07:00</authored-date>
  <message>text encoding switching</message>
  <tree>791fef41cb7999605a2593d6cefc95ce33c7f522</tree>
  <committer>
    <name>Robin Lu</name>
    <email>iamawalrus@gmail.com</email>
  </committer>
</commit>
